Power BI Case Statements


Power BI Case Statements

by Zack Cordeiro

In this blog we will show how to write case statements in Power BI, and how they differ from writing case statements in Tableau.

How do you write a CASE statement in Tableau?

Since the syntax in Tableau (VizQL) is very similar to SQL syntax writing a CASE statement in Tableau is identical.

For example, if we wanted to group our regions seen here into distinct region groups our case statement could look like this:

CASE [Region]
    WHEN "East" THEN "Group A"
    WHEN "South" THEN "Group A"
    WHEN  "Central" THEN "Group B"
    ELSE "Group C"

How Do You Write a Case Statement in Power Bi?

Writing a CASE statement in Power BI is different due to the differences of SQL and DAX syntax. Sadly, there isn’t a CASE function in DAX but there is a function that acts almost identically. For this example, we will use the SWITCH function to get the desired results.

The SWITCH function uses this basic syntax:

New Column = SWITCH(
            " condition1", "result1",
            " condition2", "result2",
            "default result"

When we write this in Power BI the steps should go like this:

  1. Start by clicking on “New column:”
  2. Type your SWITCH function in the calculation window. It should look like this:
    Region Group =
       "East","Group A",
        "West","Group A",
        "Central","Group B",
        "Group C"

You can read more about the SWITCH function here.

Additionally, you can use an IF statement to get a result similar to what you would achieve with a CASE statement in DAX. However, due to the difference between the way DAX calculates IF() the IF statement to be nested and it has the potential to get messy. For example:

Region Group =
IF (
    Regions[Region] = “East”,
    "Group A",
    IF (
        Regions[Region] = “West”,
            "Group A",
        IF (
            Regions[Region] = “Central”,
             "Group B",
            IF (

Regions[Region] = “South”,
             "Group C",

Stay tuned for more Power BI tips for Tableau Developers!

Want More Power BI Tips for Tableau Developers: Logic Plus Functions and Calculations

  1. Power BI Logic and Calculation Foundations
  2. Power BI Case Statements
  3. Recreating Level of Detail Calculations in Power BI

More About the Author

Zack Cordeiro

Analytics Consultant
Creating Navigation Buttons in Power BI Using Page Navigator One of the most unique and helpful features of Power BI as a visualization tool is its built in page navigator. Traditionally, you ...
Power BI Case Statements In this blog we will show how to write case statements in Power BI, and how they differ from writing case statements in Tableau. How do ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK


Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072


Love our blog? You should see our emails. Sign up for our newsletter!