Menu
CoddyTech

SWITCH(TRUE()) for Ranges

Part of the DAX with CALCULATE section of Coddy's Power BI journey. Lesson 20 of 24.

SWITCH(TRUE(), test1, result1, test2, result2, else): the first true test wins.

Price Band = SWITCH(TRUE(), Products[UnitPrice] >= 10, "Premium", Products[UnitPrice] >= 4, "Standard", "Budget")

Put the narrowest test first, or a wider test catches its rows.

challenge icon

Challenge

Easy

Add a column Price Band to Products: "Premium" for a unit price of 10 or more, "Standard" for 4 or more, and "Budget" for the rest.

Try it yourself

Price Band =
ProductCategoryPrice Band
EspressoCoffee
LatteCoffee
CappuccinoCoffee
Fields
  • Sales
  • Products
    • ProductID
    • Product
    • Category
    • UnitPrice
    • UnitCost
  • Stores
  • Customers
  • Dates
  • Targets

All lessons in DAX with CALCULATE