Showing results for 
Search instead for 
Did you mean: 
Community Team Member
Community Team Member


The following script will allow you to get the functionality of "Last x days" for any chosen date in the dashboard filter.


1. create a dashboard filter of type "days" and set it up to be a radio button:
2. Paste the following in the dashboard script:
var TABLE = "sales";
var COLUMN = "date";
var COUNT = 90;
dashboard.on("widgetbeforequery", function(d, a) {
     // getting item
     var item = a.query.metadata.find(function(i) { return i.panel === "scope" && $$get(i, "jaql.table") === TABLE && $$get(i, "jaql.column") === COLUMN });
     if (!defined(item)) {
          console.log("DynamicLastX: Can't find a filter item with '" + TABLE + "." + COLUMN +"' dimension. Aborting.");

         // getting member
     var members = $$get(item, "jaql.filter.members");
     if (!defined(members) || members.length !== 1) {
          console.log("DynamicLastX: Expecting single member filter. Aborting.");
     // replacing members with last/next
     delete item.jaql.filter.members;
     item.jaql.filter.last = {
          offset: 0,
          count: COUNT,
          anchor: members[0]
3. Edit the variables at the beginning of the script. 
(COLUMN: The field used in the dashboard filter
TABLE: the table that contain that field in the ElastiCube
COUNT: the number of days preceding the chose date)
var TABLE = "sales";
var COLUMN = "date";
var COUNT = 90;
Version history
Last update:
‎03-02-2023 09:12 AM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: