Reset To Default Filters When Loading Dashboard
Purpose/Benefit
Sometimes it is convenient to always reset the filters to a default state when opening a dashboard. This post describes how to achieve this with a little bit of JavaScript. When users will often be resetting filters to a default state, it is also useful to have a more prominent button to do so. This post describes how to do this as well (optional).
Prerequisites
None
Steps
STEP 1 - OPEN A DASHBOARD & OPEN THE SCRIPT EDITOR
Open the options menu in the upper right corner of the dashboard and choose the Edit Script option (as shown below).

Note: It's not always desirable to do this for all dashboards, so these steps must be taken for each dashboard that you want to have this behavior.
STEP 2 - PASTE IN THE FOLLOWING CODE SNIPPET AND CLICK SAVE
window.resetFilters = function(d) { //Function to reset the dashboard filters to the default filters. Takes parameter 'd' which is a reference to the dashboard
d.filters.clear(); //Clears current filters
d.defaultFilters.forEach(function(filter, index){ //Loop through each default filter and apply to current dashboard filters
if(index != d.defaultFilters.length - 1){ //Does not refresh filter if it is not the last filter
d.filters.update(filter,{
save:true,
refresh:false,
unionIfSameDimensionAndSameType:true
});
}
else{//Only refresh dashboard on the last filter
d.filters.update(filter,{
save:true,
refresh:true,
unionIfSameDimensionAndSameType:true
});
}
})
}
dashboard.on('initialized', function(d){ //Resets filters to default when dashboard is first loaded (or refreshed)
resetFilters(prism.activeDashboard); //Resets filters
})
(Optional) Include this code snippet after the first to create a larger copy of the reset filters button on the toolbar. This may be convenient for some users.
dashboard.on('initialized', function(sender, ev){ //Adds filter reset button to the toolbar
toolbar = $('.actions-box'); //reference to top toolbar
resetButtonHTML = "<div id=\"toolbarResetButton\" class=\"btn-immutable btn-action\" onclick=\"resetFilters(prism.activeDashboard)\" data-ng-style=\"{height: sizing.toolbar.height, \'border-left-width\': sizing.atoms.midHgap + \'px\'}\" title=\"Restore my default filters\" style=\"height: 50px; border-left-width: 30px;\"><div style=\"background-image: url(../client/resources/ux-controls/images/refresh_48.png); height: 50px; width: 50px; background-repeat: no-repeat; background-position: center\"></div>"" //button HTML with reference to resetFilters() function
if($('div#toolbarResetButton').length == 0){ //Check to see if filter reset button already exists in DOM
toolbar.append(resetButtonHTML); //Adds filter reset button to DOM
}
})
STEP 3 - ENJOY!
Your dashboard filters will now reset to their default state when a user opens the dashboard!
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022