DAX function
SWITCH(TRUE()) — DAX function reference
If / else-if chain.
Syntax
dax
SWITCH(TRUE(), <condition1>, <result1>, [<condition2>, <result2>, …], [<else>])
Examples
dax
SWITCH(TRUE(), [Margin] > 0.3, "High", [Margin] > 0.1, "Mid", "Low")
→ First true branch
dax
SWITCH(
TRUE(),
ISBLANK([Total Sales]), "No sales",
[Total Sales] >= [Target], "Hit target",
[Total Sales] >= [Target] * 0.9, "Near target",
"Below target"
)→ A multi-tier status measure, evaluated top to bottom
dax
SWITCH(TRUE(), [Days Overdue] > 90, "Critical", [Days Overdue] > 30, "Warning", [Days Overdue] > 0, "Late", "Current")
→ Aging-bucket classification
Common mistakes & gotchas
- The idiomatic way to write nested conditions in DAX.
- Branches are evaluated in order and SWITCH stops at the first TRUE condition — put the most specific/restrictive conditions first, or a broader earlier condition will shadow the ones after it.
- It's not really switching on TRUE — it's exploiting SWITCH's exact-match behavior (matching the literal value TRUE) to fake an if/else-if chain, which is why it reads oddly at first but is idiomatic in DAX.
Related DAX functions
From Logical & error handling