IFNA and the Not-Found Value
About this lesson
IFNA returns a calculation's result, unless that result is #N/A. Then it returns the value you gave instead. Every other kind of error stays visible.
- replace a lookup's #N/A with words using IFNA.
- say why IFNA is safer than IFERROR around a lookup.
- use XLOOKUP's built-in not-found argument instead.
The idea
#N/A is the one error that is often the truth. The lookup looked, and the value is not there. IFNA replaces exactly that with something a reader can act on: Not listed, Unknown, 0. It lets every other error through. A #REF! from a wrong column number still shows. That one is a mistake in the formula, not a fact about the data.
Prefer IFNA to IFERROR around a lookup for that reason. And when XLOOKUP is available, its fourth argument does the same job without a wrapper at all.
The mistake to watch for
A fallback of 0 on a price. It is convenient for the total and dangerous on an invoice, because a missing price now looks free. Choose the not-found value for the person reading the sheet. And prefer IFNA to IFERROR around a lookup, so that a broken column number still shows as the error it is.
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
In E2, look up the price of the code in D2 from the list with VLOOKUP, exact match.
To begin, type it exactly:
=VLOOKUP(D2,A2:B5,2,FALSE)
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Code | Price | Ordered | Price | |||
| 2 | P100 | 4.5 | P200 | ||||
| 3 | P200 | 7.25 | P900 | ||||
| 4 | P300 | 12 | P400 | ||||
| 5 | P400 | 3.1 | P350 | ||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
In
E2, look up the price of the code inD2from the list withVLOOKUP, exact match. To begin, type it exactly:=VLOOKUP(D2,A2:B5,2,FALSE). -
E3looks up the code inD3.P900is not on the price list, so it shows #N/A. Wrap it inIFNAso the cell reads Not listed instead. -
In
E4, the same lookup forD4with anIFNAfallback of 0, so the column can be totalled. -
E5holds=IFNA(VLOOKUP(D5,A2:B5,2,FALSE),0)andD5isP350, which is not on the list. What doesE5show? -
XLOOKUPhas the fallback built in. InF3, write a formula usingXLOOKUP, with noIFNA. It should give the price of the code inD3, or the text Not listed.