IF Function (DAX)
How does the IF function (DAX) work?
IF function (DAX) checks whether a condition is satisfied as the first statement. It returns one value if the condition is TRUE, and if the condition is FALSE returns another value.
IF Formula Syntax
IF(logical_test>,<value_if_true>, value_if_false)
How do you use the IF function?
The IF function attempts to return a single data type in a column. Therefore, if the values returned by value_if_true and value_if_false are of different data types, the IF function will implicitly convert data types to accommodate both values in the column. For example, the formula IF(<condition>,TRUE(),0)
returns a column of ones and zeros and the results can be summed, but the formula IF(<condition>,TRUE(),FALSE())
returns only logical values.
Related Blog Posts
Considerations when using the IF function
If the value of value_if_true or value_if_false is omitted, IF treats it as an empty string value (“”).
If the value referenced in the expression is a column, IF returns the value that corresponds to the current row.
Related Video Tutorials
Formula examples using the IF function
=IF([Calls]<200,"low",IF([Calls]<300,"medium","high"))
=IF([StateProvinceCode]= "CA" && ([MaritalStatus] = "M" || [NumberChildrenAtHome] >1),[City])