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 take an example, here we have a sample table which consists a supplier data as shown below.

Suppose, you want to display the status that is Level1 and Level 2 based total quantity by category.

If total quantity is >500 then display  “Level 1”  else “Level 2”. So first you need to get total quantity for each individual supplier by category.

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 we will check the total quantity, if total quantity is >500 then display “Level 1”  else “Level 2”.

Lets create 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 output.

As you can see, it returns the 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




 971 total views,  5 views today

Leave a Reply

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