Short answer: DAX logical functions build conditions and choose between results: IF and SWITCH choose, AND, OR and NOT combine tests (or the operators &&, || and IN), TRUE and FALSE are the constants, IFERROR catches errors, COALESCE returns the first non-blank value, and the BIT functions work on the bits of whole numbers. This page lists all of them with an example each.
Which functions choose a result?
| Function | Does | Example |
|---|---|---|
| IF ( test, then [, else] ) | one of two results; BLANK without else | IF ( [Margin %] < 0, "Loss", "Profit" ) |
| IF.EAGER ( test, then, else ) | like IF, but evaluates both branches first | IF.EAGER ( [Revenue] > 0, [Revenue] / 1000, 0 ) |
| SWITCH ( expr, v1, r1, ..., else ) | compares one expression with many values | SWITCH ( [Month No], 1, "Jan", 2, "Feb", "Other" ) |
| SWITCH ( TRUE (), c1, r1, ..., else ) | the first condition that is TRUE wins | SWITCH ( TRUE (), [A] >= 1, "On plan", "Behind" ) |
| IFERROR ( value, if_error ) | a fallback when the value is an error | IFERROR ( VALUE ( T[Text] ), BLANK () ) |
| COALESCE ( e1, e2, ... ) | the first expression that is not BLANK | COALESCE ( [Forecast], [Budget], 0 ) |
In depth: IF and SWITCH.
Which functions combine tests?
| Function or operator | TRUE when | Example |
|---|---|---|
| AND ( a, b ) or a && b | both are TRUE | [Revenue] > 0 && [Margin] > 0 |
| OR ( a, b ) or a || b | at least one is TRUE | Customer[Country] = "DE" || Customer[Country] = "AT" |
| NOT ( a ) | a is FALSE | NOT ( ISBLANK ( [Revenue LY] ) ) |
| x IN { ... } | x equals one of the values | Customer[Country] IN { "DE", "AT", "CH" } |
| TRUE ( ), FALSE ( ) | the logical constants | SWITCH ( TRUE ( ), ... ) |
AND and OR take exactly two arguments: three tests need AND ( a, AND ( b, c ) ) or a && b && c, which reads better.
Which functions work on bits?
| Function | Returns | Example | Result |
|---|---|---|---|
| BITAND ( a, b ) | bits set in both | BITAND ( 13, 11 ) | 9 |
| BITOR ( a, b ) | bits set in either | BITOR ( 9, 10 ) | 11 |
| BITXOR ( a, b ) | bits set in exactly one | BITXOR ( 9, 10 ) | 3 |
| BITLSHIFT ( n, k ) | n shifted k bits left | BITLSHIFT ( 2, 3 ) | 16 |
| BITRSHIFT ( n, k ) | n shifted k bits right | BITRSHIFT ( 16, 2 ) | 4 |
The common use is flag columns, where one number stores several yes or no options:
-- Features: 1 = email, 2 = SMS, 4 = push
Has SMS = BITAND ( Customer[Features], 2 ) > 0What goes wrong?
- Three arguments to AND. An error; use
&&. - BLANK in tests. BLANK compares like 0 or an empty string:
[x] = 0is TRUE for BLANK; useISBLANKor==(strict equal) when the difference matters. - IFERROR as a habit. It hides real errors and slows queries; prevent the error (
DIVIDE,ISBLANKchecks). - COALESCE with mixed types.
COALESCE ( [Revenue], "none" )makes a variant; keep one type. - SWITCH order. The first TRUE wins; put the strictest condition first.
Where can you check this?
- Microsoft Learn: Logical functions (DAX)
- Microsoft Learn: COALESCE function (DAX)
- Microsoft Learn: DAX operators
Where do you start?
Rewrite one nested IF as SWITCH ( TRUE () ) and replace IF ( ISBLANK ( x ), y, x ) with COALESCE ( x, y ). Information functions are the tests you combine.