Skip to main content

πŸ“Š Lesson 4.3: Conditional Logic β€” IFS, AND/OR, IFERROR & the *IF(S) Family

You met IF back in Lesson 2.2 β€” a cell that answers a yes/no question. Now we turn that single decision into a whole reasoning layer. You'll learn why IFS beats a pile of nested IFs, how to combine conditions with AND, OR, and NOT, how to catch errors gracefully with IFERROR and IFNA, and how the conditional-aggregate family β€” SUMIFS, COUNTIFS, AVERAGEIFS β€” totals and counts your data by category. This is the logic that turns a list into a report.

πŸ“š What You'll Learn

By the end of this lesson, you will be able to:

  • Write nested IF and understand why IFS is cleaner for several conditions
  • Combine tests with AND, OR, and NOT inside a decision
  • Catch errors gracefully with IFERROR and IFNA so a workbook stays readable
  • Use the conditional-aggregate family β€” SUMIF(S), COUNTIF(S), AVERAGEIF(S) β€” with text, number, comparison, and wildcard criteria
  • Build a small grading/status system and category totals on your own data

⏱️ Estimated Time: 50 minutes

🎯 Project: Add IFS-based status flags to your tracker, then build SUMIFS and COUNTIFS category summaries beneath it.

In This Lesson

Nested IF, and Why IFS Is Cleaner

A single IF handles a two-way choice: =IF(B2>=60, "Pass", "Fail") reads "if the score in B2 is at least 60, say Pass, otherwise Fail." That's perfect when there are exactly two outcomes. But life often has more than two β€” a grade might be A, B, C, D, or F; an order might be On track, Due soon, or Overdue. The old way to handle that was to nest one IF inside another, each one handling the next case in the "otherwise" slot:

=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))

It works, and you'll see it in older workbooks, but read it again β€” it's a thicket. Every extra grade adds another IF( and another closing ) at the far end, and a single misplaced parenthesis breaks the whole thing. Nested IFs are hard to write, harder to read, and genuinely painful to edit six months later.

IFS β€” one function, many conditions

IFS was built exactly to untangle this. You give it a flat list of condition, result pairs, and it returns the result for the first condition that's true β€” checked left to right, top to bottom. No nesting, no pile of closing parentheses:

=IFS(B2>=90,"A", B2>=80,"B", B2>=70,"C", B2>=60,"D", TRUE,"F")

Read it as a simple table of rules: "90 or more β†’ A; else 80 or more β†’ B; else 70 β†’ C; else 60 β†’ D; otherwise β†’ F." Two things to note. First, order matters β€” because IFS stops at the first true condition, you go from strictest to loosest (highest score first). Second, that final TRUE,"F" is the catch-all: TRUE is always true, so it acts as the "none of the above" default. Without a catch-all, a value matching no condition returns an #N/A error.

FunctionWhat it doesExampleResult (if B2 = 85)
IF Two-way choice =IF(B2>=60,"Pass","Fail") Pass
IFS Many conditions, first true wins =IFS(B2>=90,"A",B2>=80,"B",TRUE,"C") B

⚠️ Availability

IFS is available in Microsoft 365, Excel for the web, and Excel 2019 and later. If you're on an older perpetual version (2016 and earlier), you'll need the nested IF approach instead. Nested IF always works; IFS is just far kinder to read.

AND, OR & NOT β€” Combining Conditions

So far each test has been a single comparison. But real rules often depend on several things at once: "flag it only if the order is late and unpaid," or "highlight it if the customer is VIP or the total is large." That's what AND, OR, and NOT are for. Each takes a list of conditions and returns a single TRUE or FALSE, which you drop straight into an IF:

FunctionReturns TRUE when…Example
AND all conditions are true =AND(B2>=60, C2="Yes")
OR at least one condition is true =OR(B2>=90, C2="VIP")
NOT the condition is false (it flips it) =NOT(C2="Paid")

On their own they just return true or false, so you almost always nest them inside an IF to turn that verdict into something useful. For example, to mark an order that is both overdue and unpaid:

=IF(AND(D2<TODAY(), E2<>"Paid"), "⚠️ Chase", "OK")

Read it as: "if the due date D2 is before today and the status E2 is not 'Paid', say Chase; otherwise OK." (<> means "not equal to.") You can nest these freely β€” an OR inside an AND, an IFS whose conditions are ANDs β€” to express quite sophisticated rules while keeping each piece readable.

graph TD A["A row of data"] --> B{"Is the due date
before today?"} B -- "No" --> OK["Show OK"] B -- "Yes" --> C{"Is the status
not Paid?"} C -- "No, it is Paid" --> OK C -- "Yes, still unpaid" --> D["Show Chase warning"]

🧠 Think in plain English first

The trick to conditional logic is to say the rule out loud in ordinary words before you type it: "Chase it if it's late and unpaid." The words if, and, or, and not map almost directly onto IF, AND, OR, and NOT. Get the sentence right and the formula nearly writes itself.

IFERROR & IFNA β€” Catching Errors Gracefully

Formulas fail sometimes β€” a lookup finds nothing, a division hits a zero, a value is the wrong type. When they do, Excel shows a blunt error code like #N/A, #DIV/0!, or #VALUE!. Those are useful while you're debugging, but ugly in a finished report and they spread: one error cell can poison a SUM that includes it. IFERROR lets you catch any error and show something friendly instead:

=IFERROR(A2/B2, 0)

This says "calculate A2 divided by B2; but if that produces any error, show 0 instead." You can return anything β€” a 0, an empty string "", or a message like "Check input". It pairs perfectly with the lookups from Lessons 4.1–4.2: =IFERROR(VLOOKUP(F2,$A$2:$D$5,4,FALSE), "Not found") turns a missing code from a scary #N/A into a calm "Not found."

IFNA β€” catch only the "not found" error

IFERROR is a broad net: it swallows every kind of error, which can hide a genuine bug (a typo'd formula) behind a friendly message. When you specifically want to handle a lookup miss and still see other errors, use IFNA, which catches only #N/A:

=IFNA(XLOOKUP(F2,$A$2:$A$5,$D$2:$D$5), "Not found")

Here a genuine #N/A (code not in the list) shows "Not found," but if the formula had a different error you'd still see it and know to fix it. As a rule: reach for IFNA around lookups, and IFERROR when you truly want to mop up any error at all.

⚠️ Watch Out: don't hide real bugs

It's tempting to wrap every formula in IFERROR(..., "") to make errors "go away." Resist it. An error is Excel telling you something is wrong. Hiding it blindly means a broken calculation looks fine while quietly producing wrong totals. Catch errors you expect (a lookup that legitimately might miss); investigate errors you don't.

The Conditional-Aggregate Family

Here's where logic meets analysis. You already know SUM, COUNT, and AVERAGE from Lesson 2.2 β€” they crunch a whole range. The conditional versions do the same, but only for rows that meet a criterion: total the sales where the region is West, count the orders where the status is Overdue, average the scores where the score is above 80. This single family answers most "how much / how many, by category" questions you'll ever ask β€” and it's the engine behind a summary table.

Each comes in a single-condition flavor and a plural -IFS flavor for multiple conditions:

FunctionWhat it doesExample
SUMIF Total values where one condition is met =SUMIF(C2:C50, "West", D2:D50)
SUMIFS Total values where several conditions are met =SUMIFS(D2:D50, C2:C50, "West", E2:E50, "Paid")
COUNTIF Count rows where one condition is met =COUNTIF(E2:E50, "Overdue")
COUNTIFS Count rows meeting several conditions =COUNTIFS(C2:C50, "West", E2:E50, "Overdue")
AVERAGEIF Average values where one condition is met =AVERAGEIF(C2:C50, "West", D2:D50)
AVERAGEIFS Average values meeting several conditions =AVERAGEIFS(D2:D50, C2:C50, "West", B2:B50, ">100")

⚠️ The argument-order trap

There's a genuinely confusing inconsistency here, so memorize it. In SUMIF and AVERAGEIF, the range you're testing comes first and the range you're totalling comes last: SUMIF(test_range, criteria, sum_range). But in the plural SUMIFS and AVERAGEIFS, the range you're totalling comes first, then pairs of test_range, criteria: SUMIFS(sum_range, test_range1, criteria1, ...). The COUNT versions have no sum range at all β€” just test ranges and criteria. When in doubt, let Excel's formula tooltip guide the argument order as you type.

Writing Criteria β€” Text, Numbers, Comparisons & Wildcards

The heart of every *IF(S) function is the criteria β€” the little test each row must pass. Criteria are more flexible than they first appear, and getting them right is most of the skill:

  • Text β€” put it in quotes: "West", "Overdue". Matching is not case-sensitive, so "west" matches "West".
  • Numbers β€” just the number, no quotes needed for a plain equal: 100 counts rows equal to 100.
  • Comparisons β€” wrap the operator and value in quotes as one string: ">100" (greater than 100), "<=50" (50 or less), "<>0" (not zero). This surprises people β€” the comparison lives inside the quotes.
  • A cell reference β€” point at a cell so the criterion is live: if F1 holds the region, =SUMIF(C2:C50, F1, D2:D50) retotals the moment you change F1. For a comparison against a cell, join with &: ">"&F1.
  • Wildcards β€” * matches any run of characters and ? matches a single character. "North*" matches North, Northeast, Northwest; "?at" matches cat, hat, bat. Great for grouping messy text.
CriterionMatches
"Paid"Cells equal to the text "Paid" (any case)
">=1000"Numbers 1000 or greater
"<>Cancelled"Anything that is not "Cancelled"
"North*"Text starting with "North"
">"&TODAY()Dates after today (comparison built from a function)

Put these together and you can answer remarkably specific questions in one formula: "How many West-region orders over $500 are still unpaid?" becomes =COUNTIFS(C2:C50,"West", D2:D50,">500", E2:E50,"<>Paid"). Every extra test_range, criteria pair is another and narrowing the result. This is the exact machinery that a PivotTable (Lesson 5.1) automates with a friendly interface β€” but writing it by hand teaches you what's really happening underneath.

🎯 Project: Status Flags & Category Summaries

Now make your tracker think. You'll add a status column driven by IFS, then build a little summary block beside it that totals and counts by category with SUMIFS and COUNTIFS. Together they turn your raw list into something that reads like a report.

πŸ‹οΈ Add logic and a summary

Objective: Add automatic status flags to each row, and a small category summary that totals and counts the data automatically.

Instructions (about 22 minutes):

  1. (3 min) Pick a column with numbers to judge (a score, an amount, a days-remaining value) and add a new Status column beside it.
  2. (6 min) In the first data row, write an IFS that returns a status from the value β€” for example Overdue / Due soon / On track, or a letter grade. Include a TRUE catch-all so no row returns #N/A. Copy it down the column.
  3. (4 min) Add a rule that combines two conditions with AND or OR β€” for instance flag a row "⚠️ Chase" only when it's both overdue and unpaid.
  4. (5 min) Off to the side of your table (a few columns to the right, like column H in the hint), make a small summary: list your categories in one column, and next to each write a SUMIFS (total) and a COUNTIFS (count) for that category. Lock the data ranges with $ and reference the category cell as the criterion so you can copy the summary down.
  5. (2 min) Wrap any lookup or division that might fail in IFERROR so the report shows a clean value instead of an error.
  6. (2 min) Test that it's live: change a number or a category in the data and watch the status flags and the summary update themselves.
πŸ’‘ Hint β€” starter formulas
Status flag from a days-remaining value in D2:
=IFS(D2<0,"Overdue", D2<=3,"Due soon", TRUE,"On track")

Combined-condition flag (due date in its own column, F2, and
payment status in G2):
=IF(AND(F2<TODAY(), G2<>"Paid"), "⚠️ Chase", "OK")

Category summary (categories listed down column H, data in B and C):
Total for this category:  =SUMIFS($C$2:$C$50, $B$2:$B$50, H2)
Count for this category:  =COUNTIFS($B$2:$B$50, H2)
Average for this category: =AVERAGEIFS($C$2:$C$50, $B$2:$B$50, H2)

Safe division that never shows #DIV/0!:
=IFERROR(C2/B2, 0)

Referencing the category cell (H2) as the criterion β€” rather than typing "Groceries" β€” means you can copy the summary formulas down and each row totals its own category automatically.

βœ… Project Completion Checklist

  • A Status column uses IFS with a TRUE catch-all, copied down
  • At least one flag combines conditions with AND or OR
  • A summary block totals and counts by category with SUMIFS / COUNTIFS
  • A risky formula is wrapped in IFERROR (or IFNA) for a clean result
  • Editing the data updates the flags and the summary automatically

🎯 Quick Quiz

Question 1: Why is IFS usually better than a deeply nested IF for handling five or more outcomes?

Question 2: You want to total column D only for rows where column C is greater than 100. Which criterion is written correctly?

Best Practices for Conditional Logic

βœ… Do's

  • Reach for IFS over nested IF once you have three or more outcomes, and always add a TRUE catch-all.
  • Say the rule in plain English first β€” "if late and unpaid" β€” then translate it to IF/AND/OR.
  • Reference criteria from cells (a drop-down or a summary label) so your logic is live and easy to change.
  • Use IFNA around lookups so you catch genuine misses without hiding other bugs.

❌ Don'ts

  • Don't blanket-wrap everything in IFERROR. That hides real mistakes behind a friendly mask.
  • Don't forget the comparison goes inside quotes β€” it's ">100", not >100.
  • Don't mix up the argument order β€” SUMIF puts the sum range last, SUMIFS puts it first.

πŸ’‘ Pro Tips

  • Build criteria against an Excel Table (Lesson 3.1) so ranges grow with your data and you never re-point formulas.
  • Order IFS conditions from strictest to loosest β€” it stops at the first match, so the tightest test must come first.

πŸ““ Learning Journal

Keep a learning journal as you work through this course β€” a separate document, a note, or even a second worksheet right in the workbook you're building. After each lesson, take a few minutes to write down:

  • Key concepts you learned
  • Techniques that clicked for you
  • Questions or confusion points to revisit
  • Ideas you want to try with your own data
  • Your progress and feelings about learning this β€” including where your confidence grew

✍️ This lesson's prompt: Write out, in plain English, one decision rule you'd love your tracker to make for you ("flag it when…"). Then translate it into a formula using IF, IFS, or AND/OR. What "by category" question would a SUMIFS or COUNTIFS answer for your data?

πŸ“ Lesson Summary

πŸŽ“ Key Takeaways

  • IF is a two-way choice; IFS handles many conditions as a flat list of pairs β€” first true wins β€” with a TRUE catch-all for the default.
  • AND, OR, and NOT combine conditions into one TRUE/FALSE that slots inside an IF.
  • IFERROR catches any error and shows a friendly value; IFNA catches only #N/A β€” use it around lookups so you don't hide real bugs.
  • The *IF(S) family β€” SUMIF(S), COUNTIF(S), AVERAGEIF(S) β€” totals, counts, and averages by criteria; every extra pair is another and.
  • Criteria can be text, numbers, comparisons in quotes (">100"), cell references, or wildcards (*, ?). Mind the SUMIF vs SUMIFS argument-order difference.

πŸŽ‰ What You've Accomplished

Your spreadsheet now makes decisions and summarizes itself. You can classify every row with IFS, express multi-part rules with AND/OR, keep errors from spoiling a report, and answer "how much / how many, by category" with the conditional-aggregate family. That's the logic layer of a dashboard β€” and it's exactly the reasoning a PivotTable will soon automate for you.

❓ Common Questions at This Stage

My IFS returns #N/A for some rows. Why?

Because none of your conditions matched that row and there's no catch-all. Add a final TRUE, "default value" pair to IFS so any row that matches nothing still gets an answer instead of an error.

What's the difference between IFERROR and IFNA?

IFERROR catches every error type (#N/A, #DIV/0!, #VALUE!, and so on). IFNA catches only #N/A. Use IFNA around lookups so a legitimate "not found" is handled but a different, unexpected error still shows up for you to fix.

My SUMIFS keeps erroring β€” did I get the arguments backwards?

Very likely. SUMIFS wants the sum range first, then pairs of criteria range, criteria. That's the opposite of SUMIF, which puts the sum range last. Let Excel's tooltip prompt the order as you type each argument.

πŸ”­ Looking Ahead

In the next lesson β€” Lesson 4.4: Dynamic Arrays β€” FILTER, SORT & UNIQUE (Excel's Modern Power) β€” we meet formulas that spill whole lists of results from a single cell. You'll pull matching rows with FILTER, order them with SORT, and distill unique values with UNIQUE β€” modern superpowers that make live summaries almost effortless.

βœ… Before the Next Lesson

  • Confirm your status flags and category summary update when you edit the data
  • Try one criterion with a comparison (">100") and one with a wildcard ("North*")
  • Write your Learning Journal entry for this lesson

πŸ“š Additional Resources

🌟 Encouragement for the Journey

You just taught a spreadsheet to reason β€” to judge each row, weigh several conditions, shrug off errors, and tally itself by category. That's the difference between a list and a report. One more lesson in this module and you'll be spilling live summaries from a single formula. Keep going. πŸ“Š