Switch Statement (DAX)
column_name =
SWITCH (
condition_or_column_to_check,
condition_1, result_1,
condition_2, result_2,
condition_3, result_3,
unknown_condition_value
)
Switch Statement - Example 1 (DAX)
column_name =
SWITCH (
[ColumnA]
1, "One",
2, "Two",
3, "Three",
"Other number"
)
Switch Statement - Example 2 (DAX)
column_name = SWITCH (
TRUE()
, ([Age Group] = 1), "<= 30 Years"
, (([Age] >= 31) && ([Age] <= 40)), "< 31-40 Years"
, (([Age] >= 41) && ([Age] <= 50)), "< 41-50 Years"
, (([Age] >= 51) && ([Age] <= 60)), "< 51-60 Years"
, "> 60 Years"
)
Switch Statement - Example 3 (DAX)
column_name =
SWITCH (
TRUE,
[A] > [B], "First case",
[A] = [B], "Second case",
[A] = 0, "Third case",
"Fourth case"
)