Data Bear – Power BI Training and Consulting

Call us Today! (020) 8720 6880 |

How to Use DAX for Dynamically Switching Axes in Power BI

DAX Switching

Are you tired of toggling between multiple charts to get a comprehensive view of your data? Dynamically Switching Axes in Power BI may be the answer. Today, we’ll delve into how you can use DAX to dynamically switch axes in Power BI.

Dynamically Switch Axes in Power BI

Understanding the Power BI Data Model

Before diving into the DAX formula, it’s essential to understand the data model we’ll be working with, we have three tables:

  1. Currency Table: Holds all currency names.
  2. Sales Table: Serves as our fact table, containing fields like Sales Amount.
  3. Sales Territory Table: Contains the names of countries.

DAX Functions You Need to Know for Dynamically Switching Axes in Power BI:

Before we begin, it’s essential to familiarize yourself with some key DAX functions:

  • ROW: Creates a one-row table with specified columns and values.
  • CROSSJOIN: Combines two tables in all possible combinations.
  • VALUES: Returns a one-column table with unique values.
  • UNION: Combines two or more tables.
  • SWITCH: Evaluates an expression against a list of values.
  • HASONEVALUE: Checks if a column has one unique value.
  • TREATAS: Treats the values of a table as values in a different column.

Creating the Slicer Table with DAX:

First, we need to create a table that combines all the different categories—Currency, Country, and Region—into one single table. Here’s how you can do it using DAX Measure:

Variable1 = CROSSJOIN(ROW("Type", "Currency"), VALUES(Currency[CurrencyName]))
Variable2 = CROSSJOIN(ROW("Type", "Country"), VALUES(SalesTerritory[Country]))
Variable3 = CROSSJOIN(ROW("Type", "Region"), VALUES(SalesTerritory[Region]))
SlicerTable = UNION(Variable1, Variable2, Variable3)

Creating Dynamic Measures with DAX:

Now let’s move on to create a dynamic measure that will enable the dynamic axis switching:

DynamicMeasure =
"Country", CALCULATE(SUM(Sales[SalesAmount]), TREATAS(VALUES(SlicerTable[Key]), SalesTerritory[Country])),
"Currency", CALCULATE(SUM(Sales[SalesAmount]), TREATAS(VALUES(SlicerTable[Key]), Currency[CurrencyName])),
"Region", CALCULATE(SUM(Sales[SalesAmount]), TREATAS(VALUES(SlicerTable[Key]), SalesTerritory[Region]))

Step-by-Step Guide to Create Dynamic Axes:

  1. Create a Slicer: Drag and drop the ‘Type’ field from the slicer table to your Power BI slicer.
  2. Create a Clustered Chart: Drag and drop the ‘Key’ column for the axis and the ‘DynamicMeasure’ for the values.
  3. Single Selection: Ensure the slicer is set to ‘Single Select’ to allow only one axis to be selected at a time.


Dynamically switching axes in Power BI can provide a richer, more interactive experience for your end-users. It allows for greater flexibility in how data is presented without the need to create multiple charts for each possible view.

You can visit the rest of our blog posts for more insightful information on everything related to Power BI.

Learn more about Power BI by taking our training course.

Leave a Comment

Your email address will not be published. Required fields are marked *