cancel
Showing results for 
Search instead for 
Did you mean: 

Dashboard Filter

Lisha
8 - Cloud Apps
8 - Cloud Apps

Hi,

I had a requirement to set my Dashboard date filter to have end date as today and this should be the default filter. (eg. 1 Jan 2022 to today)

I found below script that does the job of setting today as end date dynamically.

https://community.sisense.com/t5/build-analytics/dashboard-custom-advanced-filter/m-p/3117/highlight...

Now, if I set this as default filter manually today (1 Jan 2022 to 4 Oct 2022); it will still be the default filter tomorrow unless I manually set it to tomorrow's date. I want the default filter to be reset dynamically as well. It should always be <start date> to today.

Is there a way to achieve this ?

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @Lisha ,

Try this script along with existing dashboard script.

dashboard.on('filterschanged', function (se, ev) {

	if(ev.items[0].jaql.title == 'As Of Month')
	{
		let today = new Date()
		let todayParsed = parsedDate = today.toISOString().substr(0,10)
	
		ev.items[0].jaql.filter.to = todayParsed
	
	}
});

-Hari

View solution in original post

4 REPLIES 4

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @Lisha ,

Try this script along with existing dashboard script.

dashboard.on('filterschanged', function (se, ev) {

	if(ev.items[0].jaql.title == 'As Of Month')
	{
		let today = new Date()
		let todayParsed = parsedDate = today.toISOString().substr(0,10)
	
		ev.items[0].jaql.filter.to = todayParsed
	
	}
});

-Hari

Hi @harikm007 

This script is not working as expected. As you can see the date was set to today which is correct.

Lisha_0-1664888540834.png

However, on click of restore my default filters it goes back to the default filter that was set manually earlier. The default filter was not reset to have to date as today.

Lisha_1-1664888721753.png

 

 

harikm007
13 - Data Warehouse
13 - Data Warehouse

Did you replace 'As Of Month' in above script with title of your filter ('Date')? ( I missed this to mention in above post).

 

 

Okay yes. It is working fine now. Thank you.