In this document, we will cover a use case in which a drop down will be created. Based on the values in the drop down, we will display different report in the same place. Both reports will be in the same div/container, overlays will be enable, based on the selected dropdown value either one report or other report will become active.
In this approach, we retrieve the options in dropdown are hard coded. We can use this approach when there are limited grouping columns.
For more information on the dropdown component, refer to the blog below
https://www.helicalinsight.com/dropdown-component-in-the-dashboard-designer/
- Created two separate reports. First one is traveltype wise travel cost and second is travel medium wise travel cost.
- Added the 2 reports in the dashboard designer.
- By enabling overlay, we placed these 2 reports on top of each other. For more details on overlay, refer to the blog below
https://www.helicalinsight.com/overlay-functionality-dashboard-designer/
- Create a dropdown component, provide two values in it i.e. (Travel Type, Travel Medium) and add JavaScript logic to hide or show respective reports based on dropdown value changes.
In the “On Change Event” put this specific JS code:
if(value === "Travel Type") { ['item-fsFNU'].forEach(id => document.getElementById(id).style.display = 'block'); ['item-VEGQt'].forEach(id => document.getElementById(id).style.display = 'none'); } if(value === "Travel Medium") { ['item-fsFNU'].forEach(id => document.getElementById(id).style.display = 'none'); ['item-VEGQt'].forEach(id => document.getElementById(id).style.display = 'block'); }
Note: In order to get the report ID to be used in JS code, do right click on the report then go to Advanced > CSS
Take Component ID as shown in below screenshot.
- At the dashboard level, in a specific placeholder we are only showing one report and the other reports are hidden. Hence, at the dashboard level, right click at dashboard empty area, go to JS Editor and put below JS code. If there are more reports hidden, similar things we need to do.
['item-fsFNU'].forEach(id => document.getElementById(id).style.display = 'none');
- Save all the changes and open the dashboard. It will show as below.
If we change the dropdown value, the chart has been changed automatically.