How can I write an IF statement in Power BI that includes multiple conditions?

An IF statement in Power BI allows users to create logic that evaluates multiple conditions and returns a specific result based on the outcome of those conditions. This can be achieved by using the IF function and specifying the criteria for each condition. By combining multiple conditions with logical operators such as AND or OR, users can create complex IF statements that can handle a variety of scenarios and provide accurate results. This feature in Power BI enables users to effectively analyze and make decisions based on their data by incorporating multiple conditions into their calculations.

Power BI: Write an IF Statement with Multiple Conditions


You can use the following syntax in DAX to write an IF statement with multiple conditions in Power BI:

Method 1: Write an IF Statement with OR Condition

Rating = 
IF(
   OR(
       'my_data'[Points] > 20,
       'my_data'[Assists] > 4
      ),
   "Good",
   "Bad"
)

This particular example creates a new column named Rating that returns “Good” if the value in the Points column is greater than 20 or the value in the Assists column is greater than 4.

If neither of these conditions are met, then the function returns “Bad” instead.

Method 2: Write an IF Statement with AND Condition

Rating = 
IF(
   AND(
       'my_data'[Points] > 20,
       'my_data'[Assists] > 4
      ),
   "Good",
   "Bad"
)

This particular example creates a new column named Rating that returns “Good” if the value in the Points column is greater than 20 and the value in the Assists column is greater than 4.

If both of these conditions are not met, then the function returns “Bad” instead.

The following examples suppose how to use each method in practice with the following table in Power BI named my_data:

Example 1: Write an IF Statement with OR Condition in Power BI

Suppose we would like to add a new column that contains “Good” if the value in the Points column is greater than 20 or the value in the Assists column is greater than 4.

To do so, click the New column icon:

Then type in the following formula into the formula bar:

Rating = 
IF(
   OR(
       'my_data'[Points] > 20,
       'my_data'[Assists] > 4
      ),
   "Good",
   "Bad"
)

Example 2: Write an IF Statement with AND Condition in Power BI

Suppose we would like to add a new column that contains “Good” if the value in the Points column is greater than 20 and the value in the Assists column is greater than 4.

To do so, click the New column icon:

Then type in the following formula into the formula bar:

Rating = 
IF(
   AND(
       'my_data'[Points] > 20,
       'my_data'[Assists] > 4
      ),
   "Good",
   "Bad"
)

This will create a new column named Rating that contains the value “Good” or “Bad” based on the corresponding values in the Points and Assists columns:

Note: You can find the complete documentation for the IF function in DAX .

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x