# DAX Language - IF Function

A-Badde | Posted on April 07, 20

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: ###### (0) Comments

There is no comment

##### Recent Posts
###### DAX Language - CONTAINS Function
A-Badde | May 09, 20

The CONTAINS function returns a boolean value, TRUE if each ...Read More

###### DAX Language - RANKX Function
A-Badde | May 05, 20

The RANKX function returns a single integer value that repre...Read More

###### DAX Language - AND and OR Functions
A-Badde | April 10, 20

AND/OR functions check whether all arguments are TRUE or one...Read More

###### DAX Language - Variables in DAX
A-Badde | April 10, 20

Use Var keyword to store the result of an expression as a na...Read More