Dynamic Custom Script For Dashboard Filter
Use case: Essentially we have a 'DimDate' filter set to 'This Quarter' within our dashboard which works great, but whenever we enter into the last month of a given sales quarter, we need the 'DimDate' filter to be automatically set to 'Next Quarter' instead of 'This Quarter'. Instead of manually going to the filter on the dashboard every last month of the quarter, I want to make this process automatic.
The example code is below:
dashboard.on('initialized',function(d) {
var date = new Date();
var n = date.getMonth();
if([3,6,9,12].includes(n)) {
dashboard.filters.update({ //Set the date filter to be next quarter
jaql:{
'column': 'Date',
'datatype':'datetime',
'dim': '[DIM_Date.Date]',
'filter':{
'next': {
'count': 1,
'offset': 1
}
},
'level': 'quarters',
'table': 'DIM_Date',
'title': 'My filter'
}
})
}
})
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022