Automatically Change Widget Title Based on Filter (Linux)
Summary: The discussion involves technical advice on implementing a script to automatically change a widget title based on filters in Sisense, specifically for Linux. Taras Skvarko provides a detailed script, addressing a previous issue with cascading filters and ensuring accuracy when matching the column name to a table column instead of a filter name. They invite feedback and further adjustments from other participants.
widget.on("render", function () {
let title = "name(s) selected";
// Find the "Name" filter
let filterUsed = dashboard.filters.$$items.find(
(filter) => filter.jaql.title === "Name"
);
// Get selected Name values or set default "No" text
let filterText =
filterUsed && filterUsed.jaql.filter.members?.length
? filterUsed.jaql.filter.members.join(", ")
: "No";
let isModified = false;
if (!isModified) {
widget.title = filterText + ' ' + title;
isModified = true;
}
});4. Adjust the column name under "Name" and any default text as necessary to fit your specific use case and data structure.
5. After adding the script, refresh the dashboard.
6. Validate that the widget title changes dynamically based on the current filter selection.
7. Ensure the column name in the script matches the actual filter setup.
8. Confirm that the script editor is appropriately saved and applied to the widget.
Conclusion
By following the steps outlined above, you can efficiently update widget titles to reflect filter changes, improving data navigation and user engagement on your Sisense dashboards. While this feature isn't supported natively, custom scripting provides a viable workaround for dynamic title adjustments.
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.
James Haid
·7 months agoShould this work with Sisense Cloud version 2026.1.0-d? I'd like to determine if I'm implementing this solution wrong or if the disclaimer does apply to my Sisense version. It's a perfect solution for our embedded users.
Instructions are straightforward, and I only changed "Name" on line 5 to "Time Period" to align with my dashboard filter. No other changes were made to the script. Unfortunately, there was no impact to the widget's Title.
I'd like to implement this, or a very similar solution, since several charts are dependent upon the Time Period filter, and the selected Time Period needs to be emphasized more than just existing in the dashboard filter column.
Taras Skvarko
·2 weeks agoHi @James Haid , I've tried out this implementation on the most recent versions of Sisense, and it works perfectly! Just make sure to verify that you've entered the Column Name accurately - it needs to match a table column name, rather than the filter name.
Also, the original script wasn't covering the Cascading filters scenario, so here is the updated script version:
widget.on("render", function () { let title = "full name(s) selected"; let columnName = "Name"; // your reference column // Find the filter matching the columnName (direct or inside cascading) let filterUsed = dashboard.filters.$$items.find((filter) => { if (filter.jaql?.column === columnName) return true; if (filter.isCascading && filter.levels?.some((lvl) => lvl.column === columnName)) return true; return false; }); // Get selected values or default text let filterText = "No"; if (filterUsed) { if (filterUsed.isCascading) { let level = filterUsed.levels.find((lvl) => lvl.column === columnName); if (level?.filter?.members?.length) { filterText = level.filter.members.join(", "); } } else if (filterUsed.jaql?.filter?.members?.length) { filterText = filterUsed.jaql.filter.members.join(", "); } } let isModified = false; if (!isModified) { widget.title = filterText + " " + title; isModified = true; } });Feel free to adjust it further according to your use case and let me know if it works!
James Haid
·16 hours agoHello Taras,
My apologies for the late response. I did try the script, and it works. Thank you for reviewing my response and adding the Cascading filter scenario.
I was curious if two column names could be added to the widget title, and updated your script to try it. If your curious, the below script does enable two column names to be added to a widget's title. It works for my scenario, however, I have not tested all possible dashboard filter scenarios.
// Insert selected time period and distributor into widget title
widget.on("render", function () {
let title = "Time Period";
let columnName = "tp_uom"; // 1st reference column
let title2 = "Distributor";
let columnName2 = "distributor"; // 2nd reference column
// Find the filter matching the columnName (direct or inside cascading)
let filterUsed = dashboard.filters.$$items.find((filter) => {
if (filter.jaql?.column === columnName) return true;
if (filter.isCascading && filter.levels?.some((lvl) => lvl.column === columnName))
return true;
return false;
});
// Find the filter matching the columnName2 (direct or inside cascading)
let filterUsed2 = dashboard.filters.$$items.find((filter) => {
if (filter.jaql?.column === columnName2) return true;
if (filter.isCascading && filter.levels?.some((lvl) => lvl.column === columnName2))
return true;
return false;
});
// Get selected values or default text for 1st reference column
let filterText = "No";
if (filterUsed) {
if (filterUsed.isCascading) {
let level = filterUsed.levels.find((lvl) => lvl.column === columnName);
if (level?.filter?.members?.length) {
filterText = level.filter.members.join(", ");
}
} else if (filterUsed.jaql?.filter?.members?.length) {
filterText = filterUsed.jaql.filter.members.join(", ");
}
}
// Get selected values or default text for 2nd reference column
let filterText2 = "No";
if (filterUsed2) {
if (filterUsed2.isCascading) {
let level = filterUsed2.levels.find((lvl) => lvl.column === columnName2);
if (level?.filter?.members?.length) {
filterText2 = level.filter.members.join(", ");
}
} else if (filterUsed2.jaql?.filter?.members?.length) {
filterText2 = filterUsed2.jaql.filter.members.join(", ");
}
}
let isModified = false;
if (!isModified) {
widget.title = "Time Period = " + filterText + " " + filterText2;
isModified = true;
}
});