Nishaglobal Education logo

Making decisions: IF, AND, OR, IFS and IFERROR

Make Excel decide for you: label rows with IF, combine tests with AND and OR, choose between several outcomes with IFS, and replace error messages with friendly results using IFERROR.

Lesson 4 of 1235 minQuiz: 4 questions

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

  • Write IF formulas with comparison operators
  • Combine conditions with AND and OR, and choose between many results with IFS
  • Handle errors with IFERROR
Outline
  1. What you'll learn and why it matters
  2. IF: one test, two outcomes
  3. AND and OR: more than one condition
  4. IFS: several outcomes in order
  5. IFERROR: friendly results instead of errors
  6. Practice
  7. Common mistakes
  8. Recap
  9. Quiz
  10. Mark lesson complete

What you'll learn and why it matters

Reports are full of decisions: over or under budget? Pass or fail? Which commission band? Rather than reading hundreds of rows and typing labels by hand, let a formula decide. IF is one of the most used functions in every office.

IF: one test, two outcomes

=IF(test, value_if_true, value_if_false). The test is a comparison that is TRUE or FALSE:

Worksheet: Budget

Column E labels each row Over when the actual spending (D) is greater than planned (C), and OK otherwise.
RowABCDE
1MonthCategoryPlannedActualStatus
2JanRent1500015000OK
3JanFood80008650Over
4JanTravel30002400OK
5FebRent1500015000OK
6FebFood80007900OK
7FebTravel30003600Over

Formulas (green cells)

  • E2 =IF(D2>C2,"Over","OK") → OK
  • E3 =IF(D3>C3,"Over","OK") → Over
  • E4 =IF(D4>C4,"Over","OK") → OK
  • E5 =IF(D5>C5,"Over","OK") → OK
  • E6 =IF(D6>C6,"Over","OK") → OK
  • E7 =IF(D7>C7,"Over","OK") → Over
Column E labels each row Over when the actual spending (D) is greater than planned (C), and OK otherwise.
ComparisonMeans
=Equal to
<>Not equal to
> <Greater than, less than
>= <=Greater or equal, less or equal

Text in formulas goes in double quotes ("Over"); numbers do not. The result can also be a calculation: =IF(D2>C2, D2-C2, 0) shows how much a budget was exceeded by, or 0.

AND and OR: more than one condition

AND(…) is TRUE only when all its tests are TRUE; OR(…) is TRUE when at least one is. Put them inside IF:

Worksheet: Bonus

A bonus needs sales of at least 10,000 AND a rating of at least 4.5: only Asha qualifies. A review is needed if sales are under 8,000 OR the rating is under 4: only Kofi.
RowABCDE
1SalespersonSalesCustomer ratingBonus?Review?
2Asha142504.6Yes
3Ravi98704.8No
4Meera214304.2No
5Kofi74003.9NoReview

Formulas (green cells)

  • D2 =IF(AND(B2>=10000,C2>=4.5),"Yes","No") → Yes
  • E2 =IF(OR(B2<8000,C2<4),"Review","") →
  • D3 =IF(AND(B3>=10000,C3>=4.5),"Yes","No") → No
  • E3 =IF(OR(B3<8000,C3<4),"Review","") →
  • D4 =IF(AND(B4>=10000,C4>=4.5),"Yes","No") → No
  • E4 =IF(OR(B4<8000,C4<4),"Review","") →
  • D5 =IF(AND(B5>=10000,C5>=4.5),"Yes","No") → No
  • E5 =IF(OR(B5<8000,C5<4),"Review","") → Review
A bonus needs sales of at least 10,000 AND a rating of at least 4.5: only Asha qualifies. A review is needed if sales are under 8,000 OR the rating is under 4: only Kofi.

IFS: several outcomes in order

Instead of nesting IF inside IF, IFS takes pairs of *test, result* and returns the result of the first true test. End with TRUE as a catch-all:

Worksheet: Bands

IFS checks the tests from left to right. Meera's 21,430 meets the first test, so she is Gold; Asha meets the second, Silver; Ravi meets neither, so the TRUE catch-all gives Bronze.
RowABC
1SalespersonSalesBand
2Asha14250Silver
3Ravi9870Bronze
4Meera21430Gold

Formulas (green cells)

  • C2 =IFS(B2>=20000,"Gold",B2>=10000,"Silver",TRUE,"Bronze") → Silver
  • C3 =IFS(B3>=20000,"Gold",B3>=10000,"Silver",TRUE,"Bronze") → Bronze
  • C4 =IFS(B4>=20000,"Gold",B4>=10000,"Silver",TRUE,"Bronze") → Gold
IFS checks the tests from left to right. Meera's 21,430 meets the first test, so she is Gold; Asha meets the second, Silver; Ravi meets neither, so the TRUE catch-all gives Bronze.

IFERROR: friendly results instead of errors

Some formulas produce errors, such as #DIV/0! when dividing by zero. =IFERROR(formula, value_if_error) shows your own value instead:

Worksheet: Price per unit

Dividing by 0 units gives the #DIV/0! error in D3. IFERROR in column E shows a helpful message instead.
RowABCDE
1ItemCostUnitsPer unitPer unit (safe)
2Box of pens250102525
3Sample pack00#DIV/0!No units

Formulas (green cells)

  • D2 =B2/C2 → 25
  • E2 =IFERROR(B2/C2,"No units") → 25
  • D3 =B3/C3 → #DIV/0!
  • E3 =IFERROR(B3/C3,"No units") → No units
Dividing by 0 units gives the #DIV/0! error in D3. IFERROR in column E shows a helpful message instead.
ErrorUsually means
#DIV/0!Dividing by zero or by an empty cell
#N/AA lookup did not find a match (lesson 6)
#NAME?A misspelt function name, or text without quotes
#VALUE!Maths with text, such as ="ten"*2
#REF!A formula refers to cells that were deleted

Practice

Guided exercise

Pass or fail

Marks are in B2:B5. In C2, write a formula that shows Pass for marks of 40 or more and Fail otherwise, then copy it down.

  1. In C2 type =IF(B2>=40,"Pass","Fail").
  2. Copy C2 down to C5.
Show the solution

Worksheet: Results

RowABC
1StudentMarksResult
2Asha78Pass
3Ravi35Fail
4Meera40Pass
5Kofi91Pass

Formulas (green cells)

  • C2 =IF(B2>=40,"Pass","Fail") → Pass
  • C3 =IF(B3>=40,"Pass","Fail") → Fail
  • C4 =IF(B4>=40,"Pass","Fail") → Pass
  • C5 =IF(B5>=40,"Pass","Fail") → Pass

How to get there: >=40 includes 40 itself, so Meera passes. Only Ravi, with 35, fails. The text results need double quotes; the number 40 does not.

Your turn

Over budget by how much?

For the budget rows, show how much each category went over budget (Actual minus Planned), or 0 if it did not.

Show the solution

Worksheet: Budget

RowABCDE
1MonthCategoryPlannedActualOver by
2JanRent15000150000
3JanFood80008650650
4JanTravel300024000
5FebRent15000150000
6FebFood800079000
7FebTravel30003600600

Formulas (green cells)

  • E2 =IF(D2>C2,D2-C2,0) → 0
  • E3 =IF(D3>C3,D3-C3,0) → 650
  • E4 =IF(D4>C4,D4-C4,0) → 0
  • E5 =IF(D5>C5,D5-C5,0) → 0
  • E6 =IF(D6>C6,D6-C6,0) → 0
  • E7 =IF(D7>C7,D7-C7,0) → 600

How to get there: The true result is a calculation, D − C, and the false result is 0. Food went over by 650 in January and Travel by 600 in February. You could also write =MAX(D2-C2,0).

Common mistakes

Forgetting quotes around text results

You see: #NAME?

Fix: Write "Pass", not Pass.

Putting quotes around numbers

You see: Comparisons fail, because "40" is text

Fix: Write numbers without quotes: B2>=40.

Testing the widest band first in IFS

You see: Everyone lands in the first band

Fix: Order tests from strictest to widest.

Hiding real problems with IFERROR everywhere

You see: Mistakes in formulas go unnoticed

Fix: Use IFERROR only where an error is expected, such as dividing by a count that may be zero.

Recap

  • =IF(test, if_true, if_false) labels or calculates based on a comparison.
  • AND needs all tests true; OR needs at least one. Use them inside IF.
  • IFS returns the result of the first true test; end with TRUE as a catch-all.
  • IFERROR replaces expected errors (like #DIV/0!) with a friendly value.

Key terms

Logical test
A comparison that is either TRUE or FALSE, such as B2>=40.
Nested function
A function used inside another one, such as AND inside IF.
Error value
A result such as #DIV/0! or #N/A that shows a formula could not calculate.

Check your understanding

Answer all 4 questions, then check your answers to see an explanation for each one.

  1. 1. What does =IF(B2>100,"High","Low") show when B2 is 100?

  2. 2. When is AND(B2>5, C2>5) TRUE?

  3. 3. What does #DIV/0! mean?

  4. 4. In =IFS(B2>=10000,"Silver",B2>=20000,"Gold",TRUE,"Bronze"), what does 25000 get?

Answer all 4 questions to check.

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.