Home » IF Function DAX

IF Function DAX

IF function is a Power BI logical function in DAX that checks whether a condition is satisfied, and returns one value in case of TRUE else another value in case of FALSE.





It returns a single value of any type.

If the value referenced in the expression is a column, IF returns the value that corresponds to the current row.

DAX SYNTAX

IF(<logical_test>,<value_if_true>[, <value_if_false>])

<logical_test> is any value or an expression that can be evaluated to TRUE or FALSE.

<value_if_true> is a value that is returned if the <logical_test> is TRUE.

<value_if_false> is a value that is returned if <logical_test> is FALSE. It is an optional.

Lets go through an example to see IF Function in action.

Here we have a sample table which consist a supplier data as shown in table visual.

Suppose, you want to display the status based on the category wise total quantity sum,  if total quantity sum is >500 then display  “Level 1”  else “Level 2”.

So first you need to get category wise total quantity sum for individual supplier.

Lets create a measure TotalQtySum which calculates the sum of quantity.

As you can see, TotalQtySum calculates the sum of quantity.

Now to display the status based on the check on total quantity sum, if total quantity sum is >500 then display “Level 1”  else “Level 2” ,we creates a following measure which uses IF function to check the condition.

Status = IF( [TotalQtySum] >500 ,"Level 1" ,"Level 2" )

 

Lets drag the measure into table visual to see the status .

As you can see, it returns status value Level 1 where TotalQtySum is greater than 500 else Level 2




SQL Basics TutorialSQL Advance TutorialSSRSInterview Q & A
SQL Create tableSQL Server Stored ProcedureCreate a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLESQL Server MergeCreate a Shared Data Source in SSRSSQL Server Question & Answer Quiz
SQL DropSQL Server PivotCreate a SSRS Tabular Report / Detail Report
..... More.... More....More
Power BI TutorialAzure TutorialPython TutorialSQL Server Tips & Tricks
Download and Install Power BI DesktopCreate an Azure storage accountLearn Python & ML Step by stepEnable Dark theme in SQL Server Management studio
Connect Power BI to SQL ServerUpload files to Azure storage containerSQL Server Template Explorer
Create Report ToolTip Pages in Power BICreate Azure SQL Database ServerDisplaying line numbers in Query Editor Window
....More....More....More




 465 total views,  1 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.