Dynamically Updating Widget Titles Based on Filter Selections in Sisense (Linux)
widget.on("render", function () {
let title = "by Region"; // Set a default title
// Find the specific filter by its column name
let filterUsed = dashboard.filters.$$items.find(
(filter) => filter.jaql.column === "Region"
);
// Determine the filter text or set default
let filterText =
filterUsed && filterUsed.jaql.filter.members?.length
? filterUsed.jaql.filter.members.join(", ")
: "All Regions";
// Flag to prevent multiple updates
let isModified = false;
if (!isModified) {
widget.title = filterText + ' ' + title;
isModified = true;
}
});
- Adjust the filter.jaql.column value instead of "Region" in the script to match the actual filter you intend to use.
- Update the default title instead of "by Region".
- Modify the "All Regions" value to be displayed for the “Include All” filter.
- Save the changes in the script editor.
- Apply different filter selections on your dashboard to verify that the widget title updates according to the chosen filters.
Troubleshooting and Limitations:
- Ensure that the filter column specified in the script matches an existing filter on the dashboard.
- The script works only for filters of include type. For excluding filters the additional logic should be implemented.
Conclusion
By following the steps outlined above, you can set up your Sisense widget titles to dynamically update based on filter selections. While this approach offers flexibility, it involves a custom script and requires careful handling, as modifications made this way are outside Sisense's standard support.
Disclaimer: This post outlines a potential custom workaround for a specific use case or provides instructions regarding a specific task. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. If you need further assistance with this please let us know.
4 comments
Michalis Gregoriou
·1 year agoLiliia_DevX this look great!
I have tested it and it works great!
It would be nice to have also a guide for cases you have a cascading filter!
Michalis Gregoriou
·1 year agoLiliia_DevX not sure if you had the chance to view this case.. :)
Liliia Kislitsyna
AdminOP10 months agoHi MikeGre :)
I'm afraid there is no such solution implemented, but I'm checking internally to see if we have a similar option that could help you achieve your goal.
Taras Skvarko
·10 months agoHi Liliia_DevX MikeGre , please cehck the following script with added logic to detect cascading filters and read members from level.filter.members to cover the cascading filters scenario:
I use the "Full Name" column in this example, and the default value is "No name(s) selected", where No is replaced with the actual value(s) if they are selected. Feel free to adjust it according to your needs.