Sub topic 3
IFERROR: providing a fallback when a formula fails
This chapter assumes you can enter formulas, reference cells such as B2 and ranges such as A:A, use comparison operators, and write a basic IF formula.
When a formula cannot produce a valid result, Sheets shows an error value such as #N/A or #DIV/0!. IFERROR returns a fallback value you choose when a formula returns an error. Otherwise, it returns the formula's normal result.
IFERROR: providing a fallback when a formula fails
IFERROR takes two arguments: the expression to evaluate and the fallback value.
=IFERROR(C2/D2, 0)If D2 contains 0, the division produces #DIV/0!, and the cell shows 0 instead.
IFNA: catching only #N/A
A lookup returns #N/A when it finds no match. IFNA handles only that error type.
=IFNA(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found")IFERROR would also hide other errors, such as #REF! from a broken range. Use IFNA when #N/A is the only error you expect.
When IFERROR hides real problems
For example, if a range reference in a VLOOKUP is wrong, the formula may return #REF!. Wrapped in IFERROR, that cell shows "Not found," which looks like a missing product rather than a broken formula.
Putting IFS, SWITCH, and IFERROR together
You can wrap IFS or SWITCH in IFERROR. The fallback then applies only when the whole expression fails.
=IFERROR(IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"),"Check score")Here, IFS assigns the grade, and IFERROR shows "Check score" if B2 holds an error value.
Exercise
Exercise
A VLOOKUP in Prices!A:B returns #N/A when a product is missing. Write a formula that shows "Not found" for a missing product, but still shows #REF! if the range breaks.
Show answer
=IFNA(VLOOKUP(A2,Prices!A:B,2,FALSE),"Not found")