Introduction

Depending on the values in a chart, Power BI may not start the chart’s axes at 0.

By default, it will start at the nearest value where there is increased visibility of the values. Although you can change the range of the axes manually, these changes are static.

I’m going to show you how you can provide the user the option to switch between two ranges, effectively creating Zoomed In and Zoomed Out views of the chart so the user can switch between the two views dynamically.

By starting the axes at 0 you can provide the context and overall picture to the values shown. By ‘zooming in’ you can provide clarity of the values.

I’ll start by providing the scenario, then go through the steps into how you build the zooming function.

If you’ve been a Tableau user, this method is similar to creating your own parameters, creating calculations that reference the parameters and then applying them to various settings.

Although this post will focus on using this for zooming, you could potentially use this method for more toggling and more dynamic dashboards/reports!

Scenario

Here we have an example of a scatter plot where both axes do not start at 0.

Power BI Scatter plot

Maybe we want to provide the user a bit more context and so we want to ‘zoom out’ by having the axes start at 0.

We also want to provide the user the option to zoom back in as well. How do we go about it? By creating a custom table, a slicer and some functions/measures.

The end result

Step 1: Create a table of values

If you’re familiar with Tableau, you would know that whenever you create a string parameter you can make a list of the string values you want for the parameter.

It’s a similar process in PowerBI. Except instead of a parameter we can create a table of string values we want to reference to.

Start by heading to the Home ribbon and clicking the Enter data button.

Location of the Enter data button

This will bring a popup where we can create a new table with the values we want. In this case we want the text strings ‘Zoom In’ and ‘Zoom Out’ per row.

Create Table dialog box

Newly created table and the values

With our Zoom table complete, let’s create the toggle switch that uses this.

Step 2: Create the toggle switch

Creating the switch is as easy as making a slicer based on the Zoom column and setting it to Single select.

Step by step it looks like this:

  • Select the Zoom column in the table we created earlier in the Data pane
  • Change the visualization to a Slicer
  • In the Format visual tab, ensure the Selection type is set to ‘Single select’
  • Format it however you like – Either as list, buttons or a dropdown menu

You should have a toggle switch that currently does nothing.

The next step is to create some measures that references the values (ie. “Zoom In” and “Zoom Out”) and assigns them some numbers.

This is how we make the toggle work.

Step 3: Make Minimum and Maximums

In the visualization pane, there are options to change the X and Y axes ranges for the chart. Both the minimum and maximum values can be manually set or set with a calculated measure in the Conditional formatting (fx) button.

We potentially could create up to 4 measures, each measure adjusting the minimum and maximum of each axis.

Since the minimum for both axes is 0, we are going to end up with three.

Right click on the Zoom table and select “New Measure”. Then just add the calculations. Make a new measure for each calculation.

The calculations are as follows:

  • For the Minimum to be set to 0 when we click the Zoom Out option on the slicer
    Zoom Out Start at 0 = IF(SELECTEDVALUE(‘Zoom table'[Zoom]) = “Zoom Out”,0)
  • For the Maximum value of the X-Axis I opted to grab the maximum value of that column
    Zoom Out X Axis End = IF(SELECTEDVALUE(‘Zoom table'[Zoom]) = “Zoom Out”, MAX(‘Call Centre Customer Support'[Talk Duration Total Seconds]))
  • For the Maximum value of the Y-Axis I opted to grab the maximum value of that column
    Zoom Out Y Axis End = IF(SELECTEDVALUE(‘Zoom table'[Zoom]) = “Zoom Out”, MAX(‘Call Centre Customer Support'[Satisfaction rating]))

*NB* Swap the orange section to whatever you want as your Maximum range.

Step 4: Assign the calculations

Now that we have our calculations, all we need to do is assign them to the appropriate Range using the Conditional Formatting (fx) button.

Clicking the fx buttons opens up a dialog box from which you can select the fields to set the Minimum and Maximum range of the axes.

Your selections should look like the image below.

After that test it out and see if it works!

Bonus: Text switching

Using the above concepts, you can apply the same logic to create other measures that switch around as well.

For example I created a title that showed whether the chart was zoomed in or zoomed out using the following calculation and assigning it in the conditional formatting for the Title of the chart:

Zoomed In/Out text = IF( SELECTEDVALUE(‘Zoom table'[Zoom]) = “Zoom Out”, “Zoomed Out”, “Zoomed In” )

Conclusion

In four steps we have created a toggle that zooms the chart in and out via user interaction. This will help provide more context and clarity to the user.

Feel free to use this idea and implement it in different ways. I’m excited to see other ways this idea can be implemented!

If you enjoyed this post, feel free to check out more here.

You can also connect with me on LinkedIn.

The Data School
Author: The Data School