
Power BI IF Statement: Complete DAX Guide 2026
IF function in Power BI. Nested IF, IF with AND/OR, SWITCH vs IF, CALCULATE, error handling, code examples.
IF function in Power BI. Nested IF, IF with AND/OR, SWITCH vs IF, CALCULATE, error handling, code examples.

The IF statement is the most commonly used logical function in DAX. It evaluates a condition and returns one value if TRUE, another if FALSE. In 2026, IF and SWITCH (the multi-condition successor) are foundational for enterprise Microsoft Power BI semantic models, Microsoft Power BI Copilot grounding, and Microsoft 365 Copilot data Q&A.
EPC Group has delivered enterprise DAX patterns for Fortune 500 organizations since the original Microsoft Power BI beta program (Project Crescent, 2010-2013).
| Pattern | Use Case |
|---|---|
| IF | Single condition |
| Nested IF | Multi-condition (limit 3-4 levels) |
| SWITCH | Multi-condition (cleaner than nested IF) |
| SWITCH(TRUE(), ...) | Sequential condition evaluation |
| IF + ISBLANK | Null handling |
| IF + ISERROR | Error handling |
Simple two-branch logic.
Status = IF([Total Sales] > 1000000, "High", "Low")
Use only for 2-3 conditions. SWITCH is cleaner for more.
Performance =
IF([Total Sales] > 1000000, "Excellent",
IF([Total Sales] > 500000, "Good",
IF([Total Sales] > 100000, "Average",
"Below Target")))
Performance =
SWITCH(TRUE(),
[Total Sales] > 1000000, "Excellent",
[Total Sales] > 500000, "Good",
[Total Sales] > 100000, "Average",
"Below Target"
)
Department Color =
SWITCH([Department],
"Sales", "#28A745",
"Engineering", "#007BFF",
"Marketing", "#FFC107",
"Operations", "#6C757D",
"#000000"
)
Sales Display = IF(ISBLANK([Total Sales]), 0, [Total Sales])
Margin Pct =
IF(
ISERROR([Total Sales] / [Total Cost]),
BLANK(),
DIVIDE([Total Sales], [Total Cost])
)
Better: use DIVIDE() with default value.
Margin Pct = DIVIDE([Total Sales], [Total Cost], BLANK())
DAX measure returning hex color based on condition.
Status Color =
SWITCH(TRUE(),
[KPI Performance] >= 100, "#28A745",
[KPI Performance] >= 80, "#FFC107",
"#DC3545"
)
Apply via Format → Conditional formatting → Field value.
High Value Customer =
IF(
[Total Sales] > 1000000 && [Customer Tenure Years] > 5,
"Strategic",
"Standard"
)
Or using AND() / OR() functions:
High Value Customer =
IF(
AND([Total Sales] > 1000000, [Customer Tenure Years] > 5),
"Strategic",
"Standard"
)
Customer Segment =
IF([Total Lifetime Value] > 1000000, "Tier 1", "Tier 2")
Note: Calculated columns evaluated at refresh, not at query time.
YoY Growth Status =
VAR YoYGrowth = DIVIDE([Total Sales] - [Sales Prior Year], [Sales Prior Year])
RETURN
SWITCH(TRUE(),
YoYGrowth >= 0.20, "Excellent Growth",
YoYGrowth >= 0.05, "Healthy Growth",
YoYGrowth >= 0, "Flat",
"Declining"
)
HEDIS Compliance Status =
SWITCH(TRUE(),
[HEDIS Score] >= 0.90, "Compliant",
[HEDIS Score] >= 0.70, "Approaching",
"Non-Compliant"
)
CMS Star Rating =
SWITCH(TRUE(),
[HEDIS Composite Score] >= 4.5, 5,
[HEDIS Composite Score] >= 3.5, 4,
[HEDIS Composite Score] >= 2.5, 3,
[HEDIS Composite Score] >= 1.5, 2,
1
)
Risk Level =
SWITCH(TRUE(),
[VaR] > 1000000, "High",
[VaR] > 500000, "Medium",
"Low"
)
FINRA Rule 3110 Flag =
IF(
[MNPI Trade Volume] > 0 && [Research Banking Crossover] = TRUE(),
"REVIEW REQUIRED",
"OK"
)
OEE Status =
SWITCH(TRUE(),
[OEE] >= 0.85, "World Class",
[OEE] >= 0.60, "Industry Average",
"Below Average"
)
Equipment Status =
IF(
[Last Maintenance Days] > [Maintenance Threshold Days],
"Overdue",
"On Schedule"
)
Clinical Trial Status =
SWITCH([Phase],
1, "Phase I",
2, "Phase II",
3, "Phase III",
4, "Phase IV / Post-Market",
"Pre-Clinical"
)
21 CFR Part 11 Audit Status =
IF(
[Audit Trail Complete] = TRUE() && [Electronic Signatures Valid] = TRUE(),
"Compliant",
"Non-Compliant"
)
EPC Group fixed-fee DAX measure library:
Plus Microsoft Power BI Center of Excellence: $300K-$1M (6 months).
Microsoft Power BI Copilot generates IF/SWITCH patterns from natural language. EPC Group standard requires senior architect review for performance + Microsoft Purview sensitivity tier respect.
Errin O'Connor (CEO, 4-time Microsoft Press author including Power BI book, Project Crescent original beta team) leads. Senior DAX architects with Microsoft Power BI experience since 2010.
Schedule a 30-minute DAX discovery call at /schedule or call (888) 381-9725. Senior architects (not sales) take discovery calls.
Related reading: Power BI DAX Formulas Enterprise Reference Guide, Power BI Running Total Cumulative Sum DAX Guide, Power BI Lookupvalue Function DAX Guide, Power BI Data Modeling Best Practices Enterprise Guide, and Power BI Semantic Model Enterprise Guide.
CEO & Chief AI Architect
Microsoft Press bestselling author with 29 years of enterprise consulting experience.
View Full ProfileWhy Fortune 500 enterprises are consolidating Tableau workloads to Microsoft Power BI in 2026. The 4-phase migration runbook, cost comparison, governance continuity, and Power BI Beta Team founding-member methodology from 29 years of Microsoft consulting.
Power BIMicrosoft is consolidating Power BI Premium capacity into Microsoft Fabric F-SKUs. When existing Power BI Premium customers should migrate, the F64 inflection point, and the migration playbook for Fortune 500.
Power BIPower BI May 2026 enterprise rollout: Visual Calculations GA, Exploration Perspective, Copilot Summarize. Governance patterns, migration plan, semantic model impact.
Our team of experts can help you implement enterprise-grade power bi solutions tailored to your organization's needs.