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.
Read more about this
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, type:
=VLOOKUP(D2,A2:B5,2,FALSE)
That is the price of the code in D2, exact match.
| 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, type:=VLOOKUP(D2,A2:B5,2,FALSE). That is the price of the code inD2, exact match. -
E3shows #N/A becauseP900is not on the price list. FixE3. Wrap the lookup inIFNAso the cell shows Not listed. Remember:IFNAcatches only #N/A, so every other error stays visible. -
In
E4, write the lookup forD4with anIFNAfallback of 0. Shape:=IFNA(lookup, value_if_na). Then the column can be totalled. -
D5isP350, which is not on the list. Read=IFNA(VLOOKUP(D5,A2:B5,2,FALSE),0)and say whatE5shows. -
XLOOKUPhas the fallback built in. InF3, look up the price for the code inD3withXLOOKUP. Shape:=XLOOKUP(lookup, lookup_range, return_range, if_not_found). With noIFNA, show Not listed when the code is missing.