If(conditional1, result1, condition2, result2, …, conditionalN, resultN, else-result)
This function checks multiple conditions and returns the corresponding result for the first one that is true; otherwise, the else-result is returned.
Parameters
- condition
- All conditions must be of type Boolean.
- result
- The column, expression, or literal value. Must all be of the same type as result1.
- else-result
- The column, expression, or literal value. Must be of the same type as result1. If omitted, it is assumed to be null.
Returns
The return type is defined by result1.
Remarks
The If function may contain an unlimited number of condition-result pairs. All the conditions will be verified one by one until one of them is found true. The else-result defines what statement should be executed if none of the specified conditions are true.
Examples
-
If([Priority] = "High", 100, [Priority] = "Medium", 70)
- This formula says: if the value in the Priority column is "High," then return 100. If the value in the Priority column is "Medium," then return 70. -
If([Discount] = true, [SubTotal] - [Discount Value], [SubTotal])
- This formula says: If the Discount checkbox is checked, then subtract the Discount Value from the SubTotal column value and display it. If not, then display the SubTotal value as it is.