Article

DAX Language - IF Function

DAX Language - IF Function


A.Baddane | Posted on April 07, 21

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

Leave a Comment
Add to favorite
Categories
Recent Posts
Filter column based on a list in Power Query
A.Baddane | April 05, 23

Sometimes when you work within power query, you need to filt...Read More


Use HTML in Power BI - Part 2
A.Baddane | July 05, 22

In the first blog post about using HTML in Power BI Desktop,...Read More


Use HTML in Power BI
A.Baddane | Feb. 21, 22

In this blog post, I will show you how to use HTML to create...Read More


Covid-19 Report
A.Baddane | Nov. 23, 21

The COVID-19 pandemic, also known as the coronavirus pandemi...Read More