(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to use the SWITCH function in DAX: step by step

João Barros 08 de July de 2026 4 min read

The SWITCH function in DAX lets you replace several nested IF statements with one clean, readable expression. It is perfect for turning codes into labels, building custom categories or classifying values into tiers, all inside a single measure or calculated column. Below you will see two practical patterns of SWITCH in DAX that solve most everyday cases.

Prerequisites

  • Power BI Desktop installed (or access to the Power BI Service).
  • A model with at least one data table loaded.
  • Basic knowledge of measures and calculated columns in DAX.
  • A column with values to categorize — for example, a numeric priority or a sales total.

Step 1: Understand the SWITCH syntax

The SWITCH function evaluates an expression and compares it against a list of value/result pairs. When it finds the first matching value, it returns the matching result. The last argument, optional and without a pair, works as the default value (the else).

SWITCH(
    <expression>,
    <value1>, <result1>,
    <value2>, <result2>,
    ...
    <default value>   // optional
)

Think of it as a more readable alternative to writing many IF statements inside one another.

Step 2: Create a column with a simple SWITCH

This first example of SWITCH in DAX turns a numeric code into a text label. Imagine a Tasks table with the Priority column filled with 1, 2 or 3. Create a new calculated column:

Priority Label =
SWITCH(
    Tasks[Priority],
    1, "High",
    2, "Medium",
    3, "Low",
    "Not set"
)

If Priority is 1, the column shows "High"; if it is 2, it shows "Medium"; and so on. Any other value (such as 4 or an empty field) falls into the default value "Not set". It is a quick way to make technical data readable for the end user.

Step 3: Use SWITCH(TRUE()) for tiers

A simple SWITCH only compares exact values. When you need ranges or conditions (greater than, less than), use the SWITCH(TRUE()) pattern. Instead of a value, you evaluate logical conditions from top to bottom and return the first one that is true. Create this measure:

Sales Tier =
VAR TotalSales = SUM( Sales[Amount] )
RETURN
SWITCH(
    TRUE(),
    TotalSales >= 100000, "Gold",
    TotalSales >= 50000,  "Silver",
    TotalSales >= 10000,  "Bronze",
    "Below minimum"
)

Here the measure sums sales into the TotalSales variable and then classifies it. Order is essential: because SWITCH returns the first true condition, the strictest rules must come first. A total of 120,000 is "Gold", even though it also meets the rules below it.

Step 4: Set the default value and avoid common mistakes

Always include a default value at the end. Without it, rows that match no condition return BLANK(), which usually confuses whoever reads the report. There are also two frequent mistakes to avoid:

  • Mixing data types in the results (text in one case, a number in another). Keep every result the same type.
  • Trying to use ranges in a simple SWITCH, such as SWITCH(Sales[Amount], > 100, ...). That does not work — for conditions, always use SWITCH(TRUE()).
Tip: in the SWITCH(TRUE()) pattern, put the most restrictive conditions at the top. The function stops at the first one that is true.

Check the result

To confirm it worked, drag the Priority Label column into a table visual next to the Priority column and check that each number shows the right label. For the Sales Tier measure, place it in a card or in a matrix with a dimension (for example, by region) and watch the tiers change. Also test an edge case: a priority of 4 or a very low sales value should fall into the default value you defined.

Conclusion

With these two patterns — a simple SWITCH to map values and SWITCH(TRUE()) for tiers — you cover the vast majority of classifications you will need in Power BI, with formulas that are far more readable than a chain of IF. From here, try combining SWITCH with variables for more complex logic, or use it in the conditional formatting of a visual. What is the most confusing nested IF you have ever written — and how much cleaner would it look now with SWITCH?