Nested IF, AND, OR and IFERROR: Decision Formulas Without the Headache

Nested IF, AND, OR and IFERROR: Decision Formulas Without the Headache featured illustration

📎 This article includes 1 downloadable practice file ↓

⏱ 3 min readUpdated 5 October 2026

Grades, commission slabs, eligibility checks, status labels: decision formulas are everywhere, and they’re where silent mistakes hide. The rules below keep them correct and readable.

In this article
  1. Nested IF: strictest first
  2. IFS: the same, flatter (Excel 2019+)
  3. AND and OR
  4. SWITCH for exact matches
  5. When to stop nesting: a lookup table
  6. IFERROR and IFNA, carefully
  7. Where people go wrong
  8. Continue learning

Nested IF: strictest first

=IF(B2>=90, "A+", IF(B2>=75, "A", IF(B2>=60, "B", IF(B2>=40, "C", "F"))))

Excel stops at the first TRUE. Put the highest threshold first; if you test B2>=40 first, everyone with 40 or more gets “C”.

Advertisement

IFS: the same, flatter (Excel 2019+)

=IFS(B2>=90, "A+", B2>=75, "A", B2>=60, "B", B2>=40, "C", TRUE, "F")

The final TRUE, "F" is the catch-all; without it, unmatched values return #N/A.

AND and OR

=IF(AND(B2>=40, C2>=75%), "Eligible", "Not eligible")      ' marks AND attendance
=IF(OR(D2="Gold", E2>500000), "Priority", "Standard")
=IF(AND(B2>=40, OR(C2>=75%, F2="Medical")), "Eligible", "Not eligible")

SWITCH for exact matches

=SWITCH(A2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")

When to stop nesting: a lookup table

More than four levels, or thresholds that change every year (tax slabs, commission rates)? Put them in a table and use an approximate lookup:

=XLOOKUP(B2, Bands[From], Bands[Grade], , -1)
=VLOOKUP(B2, $H$2:$I$6, 2, TRUE)

Changing a threshold then means editing a cell, not rewriting formulas. See approximate match for slabs.

IFERROR and IFNA, carefully

=IFNA(XLOOKUP(A2, Codes, Names), "Code not found")     ' only #N/A
=IFERROR(B2/C2, 0)                                      ' any error
⚠️ IFERROR hides every error, including typos and broken references. Prefer IFNA for lookups and fix real errors instead of masking them with 0.
💡 Test decision formulas on boundary values (exactly 40, 39.99, 75, blank). Boundary bugs are the most common mistake in grading and commission sheets.

Where people go wrong

Mistake Effect
Lowest threshold first Everyone lands in the first band
“>=40” typed as text Comparisons fail; write B2>=40
Blank cells Blank counts as 0 → “F”; add IF(B2=””,””,…)
⚡ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

📎 Practice files for this article

  • 📗
    IF / IFS / IFERROR scenarios workbookGrades and eligibility with nested IF, IFS, a band table and IFERROR — PASS/FAIL checks plus three mistakes that give wrong grades silently.
    ⬇ XLSX · 8 KB

Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong