Toggling Views with Bookmarks in Power BI
Bookmarks are one of my favorite features in Power BI because they allow for a lot of great customization options for user experience. In this blog, I am going to show you how to toggle between different metrics and chart types in Power BI using bookmarks.
In my last blog post, I showed you how to switch between metrics using a measures table and the SWITCH() function. Although that approach was more efficient from a performance perspective, I am going to show you how to toggle between metrics using a bookmark. As a warning, I do not endorse using this method on a large data set where performance may already be an issue. This method is best used with small data sets where loading multiple queries of the same view is feasible.
1. Create Toggles
Since we are going to be clicking on the different toggles to display different metrics, you first have to choose some sort of image/icon to put on your report canvas that allows Actions. In my example, I chose blank Buttons because it allows us to utilize Actions while still being able to have text showing (Text boxes don’t allow Actions).
Create a blank Button for each of the metrics that you want to toggle between. In the button text section of the Visualizations -> Format pane enter in the metric name.
2. Create View
Next, create a view using your desired chart elements of the first metric that you want to see. This same view will be used for the other metrics. Next, highlight all of the chart elements that are included in your view and right click -> select Group. If you navigate to the View ribbon and open the Selection pane you can see the group that you just created in that list. Double click on the grouping and rename it to reflect the metric that is being shown in the view.
Go back to the canvas and click any place within the grouping. This should highlight the group as a whole. Click Ctrl + C to copy the image and Ctrl + V to paste in a copy of the group. You can now see that the group was duplicated in the Selection pane view as well. Rename this Group to reflect the next metric you want to show. Now replace the values shown in that chart element with measure for the new metric.
Repeat this same process for all desired metrics.
3. Set Up Bookmark and Action
Go to the View ribbon and open the Bookmarks pane. Create a bookmark for each of the metrics that you want to show. In my example I have three bookmarks; Revenues, Expenses, and Profits.
Click on the first bookmark you created. This will show you all of the chart elements that are visible when choosing this bookmark. Now, hide the groups associated with the other metrics by clicking on the eyeball icon in the Selection pane. Once you have the view as you want it with only the desired metric Group visible in the view, right-click on the bookmark name and select Update. This updates the view for your bookmark.
Finally, click on the blank button you created for this metric and turn on the Actions in the Visualizations pane. Assign the bookmark that shows your desired metric to that button. Repeat this process of hiding the desired groups and updating the bookmarks for each metric that you want to show. Now test by holding Ctrl and click on the buttons to see what chart elements are left showing. Adjust in the Selection pane as necessary.
I wanted to reiterate that this is not necessarily the best way to do this as you are loading queries for each of the group views, so if you have a large data set that will take a long time to query this might be taxing from a performance perspective.
BONUS: to create the highlighted metric selection duplicate the blank button and choose a different color background for the new button. Hide the old one and update the bookmark for that metric!
Switching Chart Types
In the first section we were toggling metrics for every chart element, but in this section I am going to show you how to swap out different chart types for the same metric using the same bookmark concepts as above.
1. Create Views
In the example I will show you, I have chosen to display the revenues of college athletic departments in a bar chart by conference, a line chart by conference over time, and a donut chart of all revenues by their sources. I will use icons to select which view I’m looking at, so make sure to get images that you find representative of the chart you are trying to show. Insert those images at the top of the page. We will add actions to these images later.
First, create the different chart views that you want to be able to display in your report. These visuals will be taking the place of each other as you select different icons, so make sure that you won’t want to see them all at the same time.
2. Create Bookmarks
For each chart you want to cycle through, create a bookmark. In the screenshot below you can see that I named each bookmark after the type of chart I wanted to see to make it easy for me to remember what referred to what.
Next, using the same concept as above, right click and Update the bookmarks once the correct visual is showing using the Show this visual/Hide this visual eyeball button in the Selection pane.
3. Create Actions
Click on each of the icons that you placed at the top of the page in Step 1 and toggle on the Action button. Select Bookmark from Type and then select the bookmark that you created for that chart type. Click on each of the images at the top to make sure that only the chart you want to show is being shown.
If charts are not lining up exactly when switching between them, click on each visual and make sure that the X and Y Position of each chart is matching. You can find this in the General drop down in the Visualization pane.
Thanks so much for reading! If you have any comments, suggestions, or feedback make sure to email me at firstname.lastname@example.org.