Sub topic 13
Putting IFS, SWITCH, and IFERROR Together
Assume you know how to enter Google Sheets formulas, use cell references such as A2 and B2, compare values with operators such as >=, and write basic IF formulas. This chapter combines three functions to build decisions that are readable and safer.
A practical decision pattern
Use IFS when the input must be tested against ranges or conditions. Use SWITCH when one expression should match exact values. Wrap either function in IFERROR when unexpected input could produce an error and you have a useful fallback.
The following table shows a small order sheet:
| A | B | C | D |
|---|---|---|---|
| Customer | Score | Region code | Result |
| Ana | 87 | NY |
To classify the score in B2, use IFS. Conditions are tested from left to right, and the first true condition supplies the result.
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")The final TRUE condition catches every remaining value. Without it, a score below 70 would return #N/A. The order matters. If B2>=70 appeared first, a score of 87 would return "C" before Sheets reached the "B" condition.
Combine IFS with IFERROR
A blank cell or text such as pending may not behave like a valid score. You can return a clear message instead of exposing an error:
=IFERROR(IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"),"Check score")IFERROR evaluates the formula inside it. If that formula returns any error, IFERROR returns its second argument. This is useful for a user-facing report, but it can hide a mistake in the formula itself. Test the inner IFS formula first. Add IFERROR only after you understand which errors are expected.
Combine SWITCH with IFERROR
SWITCH is a good fit for exact mappings. This formula converts a region code in C2 into a full name:
=IFERROR(SWITCH(C2,"NY","New York","CA","California","TX","Texas"),"Unknown region")The last unpaired argument is the default result. Here, "Unknown region" is returned when no code matches. This default handles an ordinary no-match case, while IFERROR catches a separate problem, such as a broken reference or invalid expression.
You can also use SWITCH(TRUE, ...) when you want condition-based branches:
=IFERROR(SWITCH(TRUE,B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"),"Check score")This works because SWITCH compares the expression TRUE with each condition result. The first condition that evaluates to TRUE wins. IFS is usually clearer for this job, so use this pattern when the surrounding formula already benefits from SWITCH.
Choose the narrowest error handler
Google Sheets reports different errors for different problems:
| Error | Common cause |
|---|---|
| `#N/A` | No match or missing lookup result |
| `#DIV/0!` | Division by zero |
| `#VALUE!` | Wrong data type |
| `#REF!` | Invalid or deleted reference |
| `#NAME?` | Unknown function or misspelled name |
| `#NUM!` | Invalid numeric calculation |
Use IFNA when only a missing match is expected:
=IFNA(VLOOKUP(C2,Prices!A:B,2,FALSE),"Not found")Use IFERROR when several error types should receive the same fallback. Avoid returning "" automatically. A blank result can make a broken formula look correct. Prefer a message such as "Check score" or "Unknown region" when someone needs to investigate the input.
A complete combined formula
This formula classifies a score and catches invalid input:
=IFERROR(IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"),"Check score")Use IFS for ordered tests, SWITCH for exact mappings, and IFERROR or IFNA only where the fallback communicates what went wrong.
Exercise
Which formula should classify B2 as "High" when it is at least 80, "Medium" when it is at least 50, and "Low" otherwise, while displaying "Check value" for an error?
Show answer
=IFERROR(IFS(B2>=80,"High",B2>=50,"Medium",TRUE,"Low"),"Check value")