Power BI Toggle Button to Navigate Between Charts

By:   |   Updated: 2022-03-01   |   Comments (1)   |   Related: > Power BI Charts


Problem

We can use Power BI Desktop to develop more interactive reports and in this tutorial, I will cover how to create a Toggle Button using bookmark navigation to toggle between different charts.

Solution

Below are the steps to create a report in Power BI that allows the user to toggle back and forth between two different charts. Let's get started.

Step 1: Prepare Data for Power BI Visual

For this example, we will use this Excel file Long-Term-Unemployment-Statistics which you can download. This sample data looks at people that are unemployed based on age, gender and time period. Below is a sample of the data in Excel.

Source excel file of Long-Term-Unemployment detail

Step 2: Import Data for Power BI Visual

To import this Excel file, go to the Home module and click on Get Data and choose Import data from Excel.

Importing Excel File from PowerBI

Choose your file and click Open.

Choose Excel file to import Data in PowerBI

After opening the Excel file, the navigator page opens to select the appropriate data sheet. There are two options available Load or Transform Data (which allows you to transform the data with the Power Query editor). I selected Load to just load the data as is.

Imported Sheet data view

After loading the file, on the right side we can see the fields we can select for the report from the Excel sheet.

Imported and Loaded Table visualization

We can also look at the data under Table tools.

Imported and Loaded Table data visualization

Step 4: Preparing Visuals

First, I will create a rectangle shape that will contain one of the charts.

For preparing Visual, Taking a Shape as rectangle

After adding the rectangle shape into the canvas, it looks as follows.

Taking a rectangle shape into canvas

We can format the shape as needed as shown below where I changed the color.

Unfilled the color of the desired shape

Now, I am going to add a Clustered Column Chart into that rectangle shape area.

Adding a visual clustered chart on to the shape

Now, we will select Age and Unemployed for the chart as shown below.

Plotting Cluster chart respecitively

Now we will add another rectangle shape which will hold the second chart as shown below and place this over the top of the first rectangle.

Taking new shape on top of mentioned clustered chart

Then in this new rectangle I will add a Donut Chart.

Taking new visual like Donut chart on top of new shape

After adding the donut chart, I formatted it as shown below using Gender and Unemployed.

Plot the visual as per the mentioned

Now we can add our toggle buttons.

To do so select the Insert tab and then Buttons and add a blank button as shown below.

Taking a Blank Button

I selected the Button and copied it so we have 2 buttons and used a different fill color for the second button.

Copy the Button and tried to different color to it or add/changed Icon of it.

Now we need to add events to the Buttons based on the visual we want to show.

Go to View and Bookmarks.

Add Bookmark base on selection pane with respect visualize plot.

For the Gender Chart button, we need to set what we want to hide and click Add under bookmarks and give it a name which we will call GenderChart.

Setting Selection for visual effect Show/Hide and added Bookmark respecitively

For the Age Chart button, we need to set what we want to hide and click Add under bookmarks and give it a name which we will call AgeChart.

Setting Selection for visual effect Show/Hide and added Bookmark respectively.

Now if you click on a bookmark the visual will hide or show depending on the bookmark used. Below shows the GenderChart.

Set the cross visual visible on top ot the Button action

I can test the AgeChart button as follows.

Set the cross visual visible on top of the Button action

Now we can place the buttons in the same location so they are on top of each other, so it looks like only one button.

Set Both Button Properties would be same.

To toggle between the two charts, we can click the button to go back and forth as shown below in this animated image.

Report is ready with Toggle Button event.
Next Steps

Try to implement this approach for one of your reports.

Related items:

Learn more about Power BI in this 3 hour training course.


Click here to start the Power BI course






sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Bhavesh Patel Bhavesh Patel is a SQL Server database professional with 10+ years of experience.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2022-03-01

Comments For This Article




Wednesday, July 12, 2023 - 10:37:54 PM - Random Back To Top (91381)
Placing buttons on top of each other does not allow for toggling. Clicking on bar chart shows bar chart, but next time i click on it, it does not show donut chart, stays on the bar chart.
Kindly suggest improvement.














get free sql tips
agree to terms