IF Funtion
Description:
The IF function checks if a condition provided as the first argument is met, and returns one value if TRUE, and another value if FALSE.
Return Value:
IF returns a single value of any type.
Syntax:
IF( <logical_test> , <value_if_true> [, <value_if_false>] )
- Description of the parameters:
PARAMETER |
DESCRIPTION |
---|---|
logical_test |
Any value or expression that can be evaluated to TRUE or FALSE |
value_if_true |
The value that is returned if the logical test is TRUE |
value_if_false |
The value that is returned if the logical test is FALSE. If omitted, BLANK is returned |
Example:
In the calendar table, we would like to add a new column [Quarter name] using the quarter number that we already have in the table.
Quarter Name =
IF('Calendar'[QuarterOfYear]=1, "Quarter 1",
IF('Calendar'[QuarterOfYear]=2, "Quarter 2",
IF('Calendar'[QuarterOfYear]=3, "Quarter 3","Quarter 4")
)
)
The example above uses nested IF functions to assign a label as follows: "Quarter 1" if the number of the quarter is 1, "Quarter 2" if the number of the quarter is 2, "Quarter 3" if the number of the quarter is 3, and "Quarter 4" for the last one.
Related video: