WallStreetMojo

WallStreetMojo

WallStreetMojo

MENUMENU
  • Free Tutorials
  • Certification Courses
  • Excel VBA All in One Bundle
  • Login
Home » Excel, VBA & Power BI » Learn Power BI » Power BI IF Statement

Power BI IF Statement

IF Statement in Power BI

If you don’t know logical functions, then you cannot pursue a career as an analyst. Yes, this is absolutely TRUE. Without knowing logical functions, you cannot deal with a different set of calculations where the calculation requires you to test multiple logical tests in excel. The IF condition is the boss when it comes to logical tests, whether its an excel or Power BI anywhere IF statement is the boss. If you have already used the IF condition in Excel, then using it with Power BI is exactly the same. In this article, we will take you through how to apply logical IF statement in Power BI DAX formulas.

Power BI IF Statement

What is IF DAX Statements in Power BI?

IF is a logical function in both Excel & Power BI, so it used to arrive results based on logical results. Logical results are in two ways i.e., either TRUE or FALSE, so we can arrive two results based on the result of the logical test if the logical test is TRUE, one set of result or calculation and if the logical tests are FALSE second set or alternative to the first set of result.

Below is the syntax of the IF DAX statement in Power BI.

Power BI IF Syntax

  • Logical Test: For this, we need to apply what is the logical test to arrive results.
  • Result If True: If the logical test is TRUE, then what should be the result.
  • Result If False: If the logical test is FALSE, then what should be the alternative result to the first one.

If you ignore the Result If False, then we will get BLANK as a result.

Examples of IF DAX Statement in Power BI

Below are examples of the IF statement in Power BI. You can download the workbook to use the same file as we used in this example.

Popular Course in this category
Sale
All in One Excel VBA Bundle (35 Courses with Projects)
4.9 (1,353 ratings)
35+ Courses | 120+ Hours | Full Lifetime Access | Certificate of Completion
View Course
You can download this Power BI IF Statement Excel Template here – Power BI IF Statement Excel Template

Example #1

For example, look at the below set of data tables to apply the Power BI IF statement.

Power BI IF - Table Data

With this data, we need to arrive new column, i.e., “Status.”

To arrive this new column, we have a certain criterion, i.e. “if the temperature is >25, then the status should be “High,” or else status should be “Medium.”

  • Copy the above table to the Power BI file.

 IF - Table

  • Right-click on the table and choose “New Column.”

Power BI IF - New Column

  • First, give a name to this new column as “Status.”

 IF - Status

  • Open IF DAX Statement now.

Power BI IF - IF Syntax

  • The logical test is to check whether the temperature is >25 or not, so first select the temperature column and then apply the logical test as shown below.

IF Condition

Once the logical test is applied, we need to mention what the result should be if the logical test is TRUE.

  • So our result if the logical tests are TRUE i.e., If the temperature is >25, then we need the result as “High,” mention the result in double-quotes.

Power BI IF - IF Condition - High

  • Now, if the result is false, then we need the result as “Low.”

IF Condition - Low

  • Close the bracket and hit the enter key to get the result column.

Power BI IF - IF Result

Wow, there we have a new result column with a logical IF formula.

Example #2

Now assume that instead of arriving only two sets of results, we need to arrive multiple results based on multiple logical tests.

For example:

  • If the temperature is >30, status is “Heavy.”
  • If the temperature is >28, status is “High.”
  • If the temperature is >25, status is “Moderate.”
  • If the temperature is <=25, then we need the status as “Low.”

Here we need to test 4 different logical tests, so this requires nested IF conditions to be applied.

  • Open IF condition and apply the first logical test.

IF Condition - Heavy

  • The first logical condition is applied. Now we need to test other logical tests if this logical test is FALSE, so since we need to test other logical tests, open one more IF condition.

Power BI IF - IF Condition 2.1

  • This IF condition applies a second logical test and arrives the result if this logical test is TRUE.

 IF Condition High 2

  • Similarly, IF both these logical tests are FALSE, we need to do another logical test, so open another IF condition.

Power BI IF - IF Condition - Moderate

  • Like this, we have to do one more logical test if all these three logical tests are FALSE. But instead of opening one more IF condition, we can make use of the last argument i.e., “Result If False,” so this argument will be employed or used if all the applied logical tests are FALSE. So if all these are FALSE, then we need the result as “Low.”

 IF Condition - Low Condition

  • Now close brackets as many as IF conditions opened. After closing, the bracket, hit the enter key to get the new status result.

Power BI IF - IF Result 2.1

Here we have the results, like this, we can use the IF DAX function to get the conditional calculation column.

Note: Power BI IF statement file can also be downloaded from the link below, and the final output can be viewed.

You can download this Power BI IF Statement Template here – Power BI IF Statement Template

Things to Remember here

  • IF DAX function is the same as Excel IF logical function, all the arguments and application methods, everything is the same.
  • In case of multiple conditions to arrive single result, then we need to use AND & OR logical functions.
  • AND logical function is represented by the double ampersand (&&), and OR logical function is represented by double straight lines (||).

Recommended Articles

This has been a guide to Power BI IF Statement. Here we discuss how to apply the IF function in Power BI Dax formulas with the help of examples. You can learn more from the following Power BI articles –

  • VLookup Function with IF
  • Power BI Career
  • How to Create a Power BI Matrix?
  • Power BI RELATED
  • Power BI Desktop Installation
0 Shares
Share
Tweet
Share
All in One Excel VBA Bundle (35 Courses with Projects)
  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>
Primary Sidebar
Footer
COMPANY
About
Reviews
Contact
Privacy
Terms of Service
RESOURCES
Blog
Free Courses
Free Tutorials
Investment Banking Tutorials
Financial Modeling Tutorials
Excel Tutorials
Accounting Tutorials
Financial Statement Analysis
COURSES
All Courses
Financial Analyst All in One Course
Investment Banking Course
Financial Modeling Course
Private Equity Course
Venture Capital Course
Excel All in One Course

Copyright © 2021. CFA Institute Does Not Endorse, Promote, Or Warrant The Accuracy Or Quality Of WallStreetMojo. CFA® And Chartered Financial Analyst® Are Registered Trademarks Owned By CFA Institute.
Return to top

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

* Please provide your correct email id. Login details for this Free course will be emailed to you

Book Your One Instructor : One Learner Free Class
Let’s Get Started
Please select the batch
Saturday - Sunday 9 am IST to 5 pm IST
Saturday - Sunday 9 am IST to 5 pm IST

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

WallStreetMojo

Download Power BI IF Statement Template

By continuing above step, you agree to our Terms of Use and Privacy Policy.

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

* Please provide your correct email id. Login details for this Free course will be emailed to you

Login

Forgot Password?

WallStreetMojo

Download Power BI IF Statement Excel Template

New Year Offer - All in One Financial Analyst Bundle (250+ Courses, 40+ Projects) View More