0
0
Power BIbi_tool~5 mins

IF function for conditions in Power BI - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
The IF function helps you make decisions in your data by checking if a condition is true or false. It lets you show different results based on those conditions, like labeling sales as 'High' or 'Low' depending on the amount.
When you want to label sales as 'Good' if above a target and 'Needs Improvement' if below.
When you want to show 'Yes' or 'No' if a customer bought more than one product.
When you want to color code a chart based on whether values are positive or negative.
When you want to create a new column that marks orders as 'Large' if quantity is over 100.
When you want to filter data dynamically by checking if a date is before or after today.
Steps
Step 1: Click
- Modeling tab
The Modeling ribbon options appear at the top
Step 2: Click
- New column button
A formula bar opens for you to type a DAX formula
Step 3: Type
- Formula bar
The formula bar shows your typed formula
💡 Start your formula with an equal sign =
Step 4: Enter
- Formula bar
A new column is added to your table with results based on the IF condition
Step 5: Click
- Data view
You see the new column with values showing the IF function results
Before vs After
Before
Table has a SalesAmount column with numbers like 500, 1500, 300
After
New column 'Sales Category' shows 'Low' for 500 and 300, 'High' for 1500 based on IF(SalesAmount > 1000, "High", "Low")
Settings Reference
IF function syntax
📍 Formula bar when creating a new column or measure
Defines the condition to check and what to return for true or false
Default: No default, you must provide all three parts
Common Mistakes
Forgetting to include the value_if_false part in the IF function
The IF function requires three parts; missing one causes an error
Always write IF(condition, value_if_true, value_if_false) even if value_if_false is blank or zero
Using text values without quotes inside the IF function
Text must be in double quotes, otherwise Power BI treats it as a column or function name
Write text values like "High" or "Low" inside double quotes
Summary
The IF function checks a condition and returns one value if true and another if false.
Use it to create new columns or measures that categorize or flag data.
Remember to include all three parts: condition, value if true, and value if false.