## 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.

### 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.

**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 the 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.

#### Example #1

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

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.

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

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

- Open IF DAX Statement now.

**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.

Once the logical test is applied we need to mention what should be the **result 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.

- Now if the
**result is false**then we need the result as “**Low**”.

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

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

#### Example #2

Now assume 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.

- 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.

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

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

- 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**”.

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

Here we have the results, like this, we can use 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.

### 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 IF function in Power BI Dax formulas with the help of examples. You can learn more from the following Power BI articles –