Power BI IF Function DAX — Nested, SWITCH & IFERROR Examples
IF function in Power BI. Nested IF, IF with AND/OR, SWITCH vs IF, CALCULATE, error handling, code examples.

Key Takeaways
- Microsoft Power BI IF Statement DAX Guide (2026).
- TL;DR — IF / SWITCH DAX Patterns.
- Pattern 1: Basic IF.
- Pattern 2: Nested IF (Avoid for Many Conditions).
- Pattern 3: SWITCH for Multi-Condition (Preferred).
- Pattern 4: SWITCH on Single Field Value.
On this page18 sections
Microsoft Power BI IF Statement DAX Guide (2026)
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).
TL;DR — IF / SWITCH DAX Patterns
| 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 |
Pattern 1: Basic IF
Simple two-branch logic.
Status = IF([Total Sales] > 1000000, "High", "Low")
Pattern 2: Nested IF (Avoid for Many Conditions)
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")))
Pattern 3: SWITCH for Multi-Condition (Preferred)
Performance =
SWITCH(TRUE(),
[Total Sales] > 1000000, "Excellent",
[Total Sales] > 500000, "Good",
[Total Sales] > 100000, "Average",
"Below Target"
)
Pattern 4: SWITCH on Single Field Value
Department Color =
SWITCH([Department],
"Sales", "#28A745",
"Engineering", "#007BFF",
"Marketing", "#FFC107",
"Operations", "#6C757D",
"#000000"
)
Pattern 5: IF + ISBLANK for Null Handling
Sales Display = IF(ISBLANK([Total Sales]), 0, [Total Sales])
Pattern 6: IF + ISERROR for Error Handling
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())
Pattern 7: IF in Conditional Formatting
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.
Pattern 8: IF with Multiple Conditions (AND, OR)
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"
)
Pattern 9: IF in Calculated Columns
Customer Segment =
IF([Total Lifetime Value] > 1000000, "Tier 1", "Tier 2")
Note: Calculated columns evaluated at refresh, not at query time.
Pattern 10: IF with Time Intelligence
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"
)
Industry-Specific IF Patterns
Healthcare
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
)
Financial Services
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"
)
Manufacturing
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"
)
Pharma
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"
)
Performance Considerations
Best Practices
- Use SWITCH for 3+ conditions (cleaner than nested IF)
- Use VAR for repeated calculations within conditions
- Microsoft Power BI Performance Analyzer for tuning
- DAX Studio for query analysis
Common Anti-Patterns
- 5+ levels of nested IF (use SWITCH)
- IF inside iterators (often unnecessary)
- IF with redundant condition checks
- IF without ISBLANK / ISERROR for null/error handling
Microsoft Power BI Copilot + IF Statement
Copilot Prompts
- "Create a measure for high vs low sales"
- "Show me a status field based on these thresholds"
- "Add conditional logic to flag overdue items"
Copilot Best Practices
- Provide clear threshold values
- Microsoft Power BI Copilot generates SWITCH(TRUE(), ..) for multi-condition
- Always review generated DAX before production
- Microsoft Purview sensitivity respect
EPC Group DAX Engagement
EPC Group fixed-fee DAX measure library:
- Standard library: $30K-$80K (4-6 weeks)
- Industry-specific library: $80K-$200K (6-12 weeks)
- Fortune 500 enterprise library: $200K-$500K (3-6 months)
Plus Microsoft Power BI Center of Excellence: $300K-$1M (6 months).
Standard Deliverables
- DAX measure library with IF/SWITCH patterns
- Conditional formatting integration
- Microsoft Power BI Performance Analyzer optimization
- Microsoft Power BI Copilot enablement
- Documentation + training
Frequently Asked Questions
IF vs SWITCH?
- IF for 1-2 conditions
- SWITCH for 3+ conditions
- SWITCH(TRUE(), ..) for sequential condition evaluation
- SWITCH(field, ..) for single field value matching
What about Microsoft Power BI Copilot IF generation?
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.
Who delivers EPC Group DAX engagements?
Errin O'Connor (Founder & Chief AI Architect, 4-time Microsoft Press & Sams author including Power BI book, Project Crescent original beta team) leads. Senior DAX architects with Microsoft Power BI experience since 2010.
Next Steps
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.
Errin O'Connor
Founder & Chief AI Architect
Microsoft Press bestselling author with enterprise consulting experience since 1997.
View Full ProfileRelated Articles
Microsoft Fabric ROI for the CIO: Real F-SKU Costs After Build 2026
Build 2026 reshaped Fabric's TCO math. Honest F-SKU costs vs Power BI Premium, real payback periods from 12 client engagements, and the hidden cost lines Microsoft's calculator omits.
Power BITableau to Power BI Migration: Enterprise Consolidation Guide (2026)
Why 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 Microsoft consulting since 1997.
Power BIMicrosoft Fabric vs Power BI Premium: When to Migrate (2026)
Microsoft 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.
