IF is the function that lets a spreadsheet make decisions — return one thing when a condition is true, another when false. AddAND/OR for combined tests and IFERROR to handle problems cleanly, and you can encode real business logic.
IF
=IF(B2 >= 40, "Pass", "Fail")=IF(sales > target, sales * 0.1, 0) (bonus only if over target)=IF(stock = 0, "Out of stock", stock)
Nested IF & IFS
To pick between more than two outcomes, nest IFs — or use the cleaner IFS (modern Excel):
Nested IF:=IF(B2>=90,"A", IF(B2>=75,"B", IF(B2>=40,"C","F")))IFS — reads left to right, first match wins:=IFS(B2>=90,"A", B2>=75,"B", B2>=40,"C", TRUE,"F")(TRUE = the catch-all "else")
AND / OR / NOT
=IF(AND(score>=40, attendance>=75), "Eligible", "Not eligible")=IF(OR(region="North", region="East"), "Priority", "Standard")=IF(NOT(paid), "Send reminder", "")
IFERROR
Formulas fail — a lookup finds nothing, a division hits zero. IFERROR catches the error and returns a friendly value instead of an ugly #N/A or #DIV/0!:
=IFERROR(A2/B2, 0) (0 instead of #DIV/0!)=IFERROR(XLOOKUP(id, ids, names), "Not found")
Practice
Grade scores into A/B/C/F with IFS. Flag students as "Eligible" only if score ≥ 40 and attendance ≥ 75 using AND. Compute a ratio that safely returns 0 on divide-by-zero with IFERROR.
Key takeaways
- 01IF(test, if-true, if-false) makes a cell decide between two outcomes.
- 02For many outcomes, use IFS (with a final TRUE catch-all) instead of deeply nested IFs.
- 03AND/OR/NOT combine conditions inside an IF.
- 04IFERROR(value, fallback) replaces errors (#N/A, #DIV/0!) with a friendly result.
- 05A wall of nested IFs signals you want IFS or a lookup table instead.
