Skip to main content

By Errin O'Connor, Founder & Chief AI Architect, EPC Group

HomeBlogPower BI
Back to BlogPower BI

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.

EO
Errin O'Connor
Founder & Chief AI Architect
February 3, 2026
4 min read
Power BIDAXIF StatementTutorial
Power BI IF Function DAX: Nested, SWITCH & IFERROR Examples

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.

Share this article:
EO

Errin O'Connor

Founder & Chief AI Architect

Microsoft Press bestselling author with enterprise consulting experience since 1997.

View Full Profile

Need Help with Power BI?

Our team of experts can help you implement enterprise-grade power bi solutions tailored to your organization's needs.

Related EPC Group Services

AI assistant — not human