How to create a toggle button in Power BI
In this blog post I will be showing you how to use a toggle button in Power BI. A toggle button in Power BI allows users to quickly switch between two options.
Our first step is to create a toggle button as Power BI doesn’t have one by default. You can import one but by creating it yourself, it gives you more control.
Our toggle button is created by having two images of identical size over the top of each other and using bookmarks to flip between the two. Therefore, you can create your images using any software you like. I’ll be using PowerPoint and importing shapes.
In PowerPoint, import the Flowchart: Terminator shape.
Then, import an oval and shape it into a circle. Change the shape fill to white or grey and move the circle so that it fits inside the curve of the curved rectangle.
Once that is done, copy and paste the shapes that form the toggle button and move the white circle to the other side of the curved rectangle. Next, import a textbox over the shapes and include the text you would like for the toggles.
My Power BI report is going to toggle world record times between Men and Women, so my toggles look like this:
It is crucial that these images are the same size, therefore we need to make sure there is no whitespace around the toggle images. To ensure this. I copy the two images into everyone’s favourite image editor – Microsoft Paint! There, crop all the whitespace around the shapes before saving the images as .png files.
It is now time to import these two created images into Power BI and align them such that they’re directly on top of each other. This is required because the image’s visibility will be toggled to give the impression it’s one button instead of two images. You can ensure the images are exactly aligned using the position and size properties.
Toggling the visibility of the images and associated charts is done using bookmarks. The below screenshot shows for the Women’s bookmark: all men related items are hidden and all women related items are shown.
The final step is to action the images such that when clicked on, the bookmark is activated and toggles to the other image and charts. When the women’s toggle is clicked activate the men’s bookmark.
Hopefully you should end up with something like this:
Clicking on the toggle in the top right corner toggles us to the women’s chart.
Clicking on the toggle in the top right corner again takes us back to the men’s chart.
This is my 2nd blog post that uses PowerPoint to enhance my Power BI experience, please see the first blog post here: https://www.purplefrogsystems.com/blog/2019/12/creating-power-bi-layouts-using-powerpoint/