How To Add Toggle Button In Power Bi

How to Add Toggle Button in Power BI

A toggle button is a user interface element that allows you to switch between two states, usually on/off or true/false. Adding a toggle button in Power BI can be done using the following steps:

Step 1: Create a New Power BI Report

Open Power BI Desktop and create a new report or open an existing one.

Step 2: Add a Button Visual

Click on the “Insert” tab in the top menu and select “Button” from the Visualizations section. This will add a button visual to your report.

Step 3: Customize the Button

With the button visual selected, you can customize its appearance by changing the color, size, and text. You can also position and resize the button as needed.

Step 4: Create a Measure for Toggle

In order to toggle the button’s state, you need to create a measure that will change based on a condition. For example, you can create a measure called “ToggleState” with a formula like:

ToggleState = IF(MAX('Table'[State]) = "On", "Off", "On")

This measure checks the current state of a column named “State” in a table named “Table”, and if it is “On”, it sets the measure value to “Off”, otherwise it sets it to “On”.

Step 5: Bind Button Text and State

To bind the button’s text and state to the measure, you need to go to the button visual options and modify the properties:

  • Under the “Button Text” section, select the “ToggleState” measure as the text field.
  • Under the “State” section, choose the “ToggleState” measure as the toggle state field.

These settings will update the button’s text and state based on the measure’s value.

Step 6: Test the Toggle Button

Now you can test the toggle button by changing the state of the column used in the measure. This will update the button accordingly.

By following these steps, you can successfully add a toggle button in Power BI.

Example:

<div>
  <h2>Toggle Button Example</h2>

  <!-- Power BI Report with Toggle Button -->
  <iframe width="800" height="600" src="https://app.powerbi.com/view?r=xxxx&embed=1" frameborder="0" allowFullScreen="true"></iframe>
</div>

In the above example, you can replace “https://app.powerbi.com/view?r=xxxx&embed=1” with the actual URL of your Power BI report that contains the toggle button visual.

Read more

Leave a comment