Contact us


Knowledge base

home banner

  • Knowledge

  • Categories

November 13, 2020

DAX function SWITCH

Author: Branka Trifunović

For Power BI version 2.76.5678.782 (December 2019).

Function SWITCH() reads the value of the expression, compares it and returns a result from a pre-defined list. It is a key function used with unconnected table.


SWITCH(Expression, Value1, Result1 [, Value 2, Result2, Value 3, Result3…] [, ElseValue])

Parameter Description
Expression Expression, evaluated to scalar value
Value1, Value2, Value3,… A value to be compared to the expression result
Result1, Result2, Result3, … Result in case value matches the result of the expression
ElseValue Result in case result

Example: days of the week

We have a table column with number of the day Day. We want to switch numbers for days.

We add a new column by selecting New Column and using SWITCH() function.

SWITCH_Example = SWITCH(‘Weekday'[Day], 1, “Monday”, 2, “Tuesday”, 3, “Wednesday”, 4, “Thursday”, 5, “Friday”, 6, “Saturday”, 7, “Sunday”)