Power BI IF Statement Measure + Examples

This Power BI tutorial will help you work with Power BI IF Statement Measure.

We recently worked on a Power BI Report where the IF() function helped me create a column based on another column.

In this tutorial, we will see the IF statement measure in Power BI and a real-time example of how to use the SUM measure in Power BI. Also, we will see how to work with Power BI measure IF multiple conditions.

Power BI IF Statement Measure

In Power BI, an IF statement in a measure is a way to create a logical condition that evaluates whether a specific condition is true or false and then returns one value if TRUE and another value if FALSE.

Syntax:

IF(logical_condition, value_if_true,[value_if_false])

Where:

  • logical_condition = Any expression that can be evaluated as True or False
  • value_if_true = Return a value if the expression is true
  • value_if_false =Return a value if the expression is false. If omitted, BLANK is returned.

Example:

Suppose you have a dataset with a Sales Amount column, and you want to create a new column(Sales Status) that categorizes each sale as High or Low based on the sales amount.

In this example:

If the Sales Amount exceeds 10000, then the Sales Status is set to “High. Otherwise, “Low“.

Sales Status = 
IF(
    'Sales'[Sales Amount] > 10000, 
    "High", 
    "Low"
)
IF Statement in Power BI Measure

Result:

Here, you see the result of the If statement in the Power BI table visual.

power bi measure if else

This is the Power BI Measure if statement.

Power BI IF Statement Measure Example

Here, I will show you steps to create an if statement using the measure in Power BI.

I have a SharePoint list that I am using in this tutorial.

ColumnsData Types
SegmentSingle line of text
CountrySingle line of text
ProductSingle line of text
SalesCurrency
ProfitCurrency
Units SoldNumber
Gross SalesCurrency
How to Write a Multiple IF Statement in Power BI

1. Open Power BI Desktop and load the data. Then, you see data in the Data pane.

How to Write If Statement in Power BI

2. Under the Home tab, click on the New measure.

IF condition in power bi Measure

3. In the formula bar, click the below expression. Then click Commit.

Here, If the sum of the sale price is greater than or equal to the sum of the Gross Sales, it returns Up. Otherwise, it returns Down.

Up/Down Calculate =IF(
		SUM('Financial Sample'[ Sales]) >= SUM('Financial Sample'[Gross Sales]),
		"Up",
		"Down"
	)

Where:

  • Up/Down Calculate:- Name of the measure
  • SUM = Function Name
  • Financial Sample = Table Name
  • Sales, Gross Sales = Column Name
How to correctly use IF in Power BI DAX

4. Under the Home tab, expand Visual gallery(black box) -> Click the Table visual.

Power BI Measure if statement

5. Then, using the +Add data option, add Product, Segment, Sales, Gross Sales, Up/Down Calculate into Columns field in the table visual.

how to use if statement in measure power bi

6. Next, the Up/Down Calculate column is in the table visual.

How to write IF STATEMENTS in Power BI measure

This way, you can use a measure to create and use a Power BI IF statement.

Power BI Measure IF Multiple Conditions

I will tell you what Power BI measures if multiple conditions exist and how to create them.

Using multiple IF conditions in Power BI measures allows for the change in their values based on different criteria. It’s like saying, If this condition is met, do this; if another condition is met, otherwise do something else.

Syntax:

IF(logical_condition, value_if_true,
     IF(logical_condition, value_if_true,
          IF(logical_condition, value_if_true,[value_if_false])
     )
)

Where:

  • logical_condition = Any expression that can be evaluated as True or False
  • value_if_true = Return a value if the expression is true
  • value_if_false =Return a value if the expression is false. If omitted, BLANK is returned.

Example :

Suppose you have a dataset with a Sales column, and you want to create a new column that categorizes each sale as “High,” “Medium,” or “Low” based on the sales amount.

In this example:

  • If the Sales Amount is greater than 10000, the category is set to “High.”
  • If the Sales Amount is between 5000 and 10000, the category is set to “Medium.”
  • If the Sales Amount is 5000 or lower, the category is “Low.”

To do this example in Power BI measure, put the below expression

Sales Category = 
IF('Order'[Sales Amount] > 10000, "High",
    IF('Order'[Sales Amount] > 5000, "Medium", "Low"))

Where:

  • Sales Category = Name of the measure
  • Order = Table Name
  • Sales Amount = Measure
How to Use 2 Conditions in If Function Power BI

Result:

Here, you see the result of the multiple If statement in the Power BI table visual.

Power BI Measure If Multiple Conditions

This is how to do Power BI multiple if conditions using the measure.

Conclusion

Power BI IF statement in a measure is a way to create a logical condition that evaluates whether a specific condition is true or false.

Now, you know about the Power BI IF Statement Measure. This tutorial taught us what the Power BI IF statement measures and how to use the IF statement in the Power BI measure. Additionally, we explained Power BI Measure IF Multiple Conditions.