Recently one of our clients came to us wanting to know if we could show or hide a visual in Power BI based on a slicer selection. Importantly, the requirement was based on a slicer selection and not a button – this means Power BI bookmarks were not an option.
There are a number of scenarios where you might want to do this. For example, a visual may be relevant only for recent reporting periods which means you might want to show a visual if the report users selects 2019 or later and hide the visual if the user selects 2018 or earlier.
Alternatively, a certain split in the data might only be relevant for a certain product or category. For example, Category A, B, C don’t have a subcategory but Category D does and therefore when the user slices on Category D you might want to show the subcategory visual.
Reporting Period Example
(2019 Reporting Year)
(2018 Reporting Year)
With a bit of Power BI trickery this can be achieved:
Create one of these measures depending on your use case:
ShowHide = IF(MAX([Year]) >= 2019,0,1)
ShowHide = IF(MAX([Category]) = “Category D”,0,1)
Create a Treemap visual and drag the ShowHide measure on to Values
Adjust the field colour on the Treemap visual to white
Set the background transparency of the Treemap visual to 100%
Turn off Visual Heads in the formatting pane of the Treemap
Position the Tree Map in front the visual you want to show or hide (as below)
Test and Enjoy!
(Reporting Period) - Red Box indicates blank Treemap visual
Hope this is useful! Any questions or comments please feel free to leave below, or alternatively you can contact us at firstname.lastname@example.org