Forum Discussion
tomlinton
05-02-2022Sisense Employee
Hi - there is no "getDate()" functionality that I am aware of to be used here. Have you explored the "Time Frame" filter where you can set offsets? See the screenshot attached. Based on the date level you select, it will allow you to offset based on today's date. In my example, I am selecting yesterday. Would that work for you? The only downside is that this would only work if you are trying to do a rolling X number of days.
There is definitely a way to set the anchor date like you have done and programmatically change the "to" date with a dashboard script. You would basically grab the filters on dashboard initialization and set the "to" date.
Here is some code that I used in the dashboard script:
dashboard.on('initialized',function(s,e) {
let newFilter = e.dashboard.filters.item(0);
let today = new Date()
let todayParsed = parsedDate = today.toISOString().substr(0,10)
newFilter.jaql.filter.to = todayParsed
e.dashboard.filters.update(newFilter,{refresh: true, save: true})
});