In the previous post, I explained a usage of bookmarks and buttons in Power BI, which was for clearing all slicers. Buttons and bookmarks are the gold combination in Power BI. You can do wide range of creative activities with this combination. In this post, I will show you some other usages of buttons and bookmarks which is related to visual’s interactions. we are going to learn about;
- Changing the chart type dynamically
- Changing the axis of charts dynamically
- Changing font sizes of a chart dynamically
- Changing color of a chart dynamically
There are heaps of more examples can be done with buttons and bookmarks, but these few will take the entire full blog post here. If you want to learn more about Power BI, read the Power BI book; from Rookie to Rock Star.
Key Components of the Design
The key components of designing examples below, are three settings; Bookmarks, Buttons, and Selection Pane.
Bookmark saves the state of the page, exactly as it is at the time of saving a bookmark. This means you can then select the bookmark and see the page with the state that you have saved it. Bookmark is not a screenshot, it will be an interactive Power BI report page, with a state saved as is.
You can hide or unhide visuals in a Power BI report through the selection pane. there is an eye icon besides every visual, which gives you the control over visibility of that visual on the report page.
Buttons are action objects in Power BI. You can create a button (or even an image or shape), and then set the action of that to be; back, Q&A, or bookmark. In this post, we are only talking about the bookmark action feature.
Combination of the three above; Magic
when you combine the three features above, you can make the magic happens! You can put visuals on top of each other, and then hide or unhide them, add a bookmark, and connect the action of button to that bookmark. examples below are just very few examples of the thousands of possibilities with this magic combination!
Changing the Chart Type Dynamically
Consider the report below;
The chart in the left-hand side is a column chart. the three charts in the right-hand, are however, images (or logos). I want to select the image in the right-hand side and then change the chart type in the main section (left-hand) with that. let’s see how we can do that.
Step 1: Create multiple visuals
First step is to create multiple visuals on top of each other. create a copy of this chart, and convert it to Bar chart, then create another copy of this, and convert it to line chart. here are all charts on top of each other.
Step 2: Selection Pane
Now click on the selection Pane in the View tab.
After selecting this item, you will see the selection pane, with list of all visuals. Notice that there is an eye icon besides every visual. that is the setting for hide/unhide the visual in the page.
Step 3: Unhide other visuals
From the list of three charts on the page, unhide two of those. in the screenshot below, then one which is not hided, is the column chart.
Step 4: Create a bookmark
Now to save the state of the page as is, create a bookmark (you have to select the bookmark pane in the View tab first). I called this new bookmark as “When Column”
Step 5: Connect button to the bookmark
Now that you have created the bookmark. Click on the button (in this case image boxes of charts in the right-hand side), and set the action of those to bookmark, and choose the right bookmark for it.
Step 6: Repeat this process for the other two types of charts.
Create two other bookmarks when you have selected the other two charts individually, and then assign their buttons to those bookmarks.
Testing the result
Now is the time to test the result, here you go; you can change the chart type dynamically in a Power BI report page.
Changing the Axis of Chart Dynamically
Another example of the magic combination (bookmarks, buttons, and selection pane); is to change the axis of chart dynamically. Here is the report below;
As you can see in the screenshot above, the buttons provided are for two fields; By Education, and By Occupation. I want to change the X Axis of the chart to the Education or Occupation field with choosing the buttons respectively.
The way I implemented this feature, is by creating two charts overlayed on top of each other; first chart by Eduction, second chart by Occupation. then hiding one, creating bookmark, and doing the same for the other one. then mapping the action of buttons to these bookmarks. screenshot below shows how these steps are done.
And here is the result;
Changing the Font Size Dynamically
We can use the same approach to change the font size. This time you have to create one chart with each different font size you want, and create buttons and bookmarks repective to that. Here is an example video:
Changing the Color of Chart Dynamically
Another example is to change the data color in a chart dynamically. This time, buttons represent different colors, and you have the chart copied but with different color. each bookmark save the state of the chart when that color is selected in the button. result would be similar to below;
The Magic Three: Bookmark, Button, and Selection Pane
With the magic triangle of bookmarks, buttons, and the selection pane, you are only limited to your creativity. You can do many things that looks impossible in Power BI dynamically and give the power of extra features to the users. I have written another post, that explains how you can clear all slicers with bookmarks and buttons. There are heaps of other examples you can do with this magic triangle. Do you have a scenario that you have used these or want to use these? feel free to share it in the comments below.