cancel
Showing results for 
Search instead for 
Did you mean: 

Dashboard Custom advanced Filter

jacobgould
7 - Data Storage
7 - Data Storage

I'm attempting to create a custom(advanced script) date filter on a widget. My  base table has dates in the future for forecast planning, but I only want the widget to show results

 

from: "2020-01-03"  

to: "today". (I want getdate() or similar)

Is there a getdate() like function I can add into the code under advanced? 

 

jacobgould_0-1651157027913.png

 

1 REPLY 1

tomlinton
Sisense Team Member
Sisense Team Member

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})
	
});