How to show & hide visuals using Power BI Bookmarks & a Button.

There are different ways to show/hide an object on the Power BI canvas base on user input, conditions, values, etc. This is the first post of a series of posts that describes different methods to do that for different use cases.

In this post, we are going to discuss how to show/hide an object using Power BI bookmark and a button and then we going to find out how to bring slicer selection applied to visuals while a slicer is hidden.

Hide/Show a chart

We have 3 objects on the canvas initially.

  • Object (Chart) we want to hide/show
  • Hide rectangle
  • Show rectangle

Hide/show rectangles are just regular rounded rectangles formatted to look like hide/show buttons.

You can find these shapes at Insert >> Shapes. We’re going to assign button action to both rectangles later.

And we have a simple pie chart.

Create bookmarks

Bookmark in Power BI is a snapshot of a report you can save and view later. You can save details including filters, selections, sort order, etc.

Go to View >> Bookmark to open up the Bookmarks pane.

Click Add to add bookmarks. We need to save 2 bookmarks with the chart hidden state and shown state. Right-click and rename 2 bookmarks meaningfully.

At this point 2 bookmarks are identical. When you click on it you will see the same set of objects on the canvas. We need to update Shown Bookmark to have the chart and the Hide button and update the Hidden bookmark to have only the show button.

To do that go to View >> Selection to open up the Selection pane.

Select the Shown bookmark and hide the objects we don’t need on it.

Then right-click on the bookmark and click Update.

Select the Hidden bookmark and hide the objects we don’t need on it and update the bookmark.

Now we have 2 bookmarks that show 2 different states of the canvas. Next, we’re going to assign bookmark switching action to 2 rectangles we have on the canvas.

Create buttons

Select Hidden bookmark in which the Hide rectangle exists, Select Hide rectangle. Format Shape >> Turn on Action. On the Type field, select Bookmark, and on the Bookmark field, select the Hidden bookmark. For the Show button in Shown bookmark assign the Hidden bookmark.

With these settings, 2 rectangles in 2 bookmarks work as buttons that bring up the bookmark it was assigned with.

You can use this method to show/hide generally any object on the canvas.

How to Hide/Show a slicer in Power BI

What if we have a slicer on the report and we need to show the slicer when we need to use slicer and need to keep the slicer hidden when we see the chart and most importantly we need to keep all slicer selections applied to the chart while the slicer is hidden.

Let’s develop this simple report to include a working slicer.

add a slicer and update 1st bookmarks 2 show it and the 2nd to hide it. Now when you try applying some slicer selection and click buttons and you will notice that all selections are cleared when you switch between bookmarks just as we expected.

To keep all selections on and apply them across bookmarks, right-click on 2 bookmarks and untick Data.

This action will keep all filters, drills, and sort orders intact while we are switching bookmarks.