XLOOKUP misses without blowing up (IFERROR)
The problem
Problem statement
Customer service keeps typing SKUs that stopped existing, and every miss splatters #N/A across the price report. Look up the price for the SKU in E2 from the list in A2:C6, and return the text "Not found" instead of an error. Fill the Price cell F2 — two ways solve this, and one of them doesn't even need IFERROR.
Put the fallback in the second argument (or XLOOKUP's 4th) — case 2 is unmatched and must return "Not found", never #N/A.
Problem data
Show the sheet as a table (selectable, copyable)
| A | B | C | E | F | |
|---|---|---|---|---|---|
| 1 | SKU | Product | Price | Lookup SKU | Price |
| 2 | SKU-1001 | Kettle | 89 | SKU-1043 | |
| 3 | SKU-1017 | Mug | 12 | ||
| 4 | SKU-1043 | Teapot | 249 | ||
| 5 | SKU-1088 | Tray | 35 | ||
| 6 | SKU-1102 | Coaster | 9 |
Notes
Two idiomatic fixes. The classic: wrap the lookup — =IFERROR(XLOOKUP(…), "Not found"). The modern one: XLOOKUP has a built-in 4th argument, if_not_found — =XLOOKUP(E2, A2:A6, C2:C6, "Not found") handles misses natively with no wrapper. Prefer the 4th argument when your audience has modern Excel: it only traps misses, whereas IFERROR also swallows real breakage like #REF! from deleted columns.
How to approach
Your answer goes in F2. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.
- Target cell is F2
- The raw lookup is the
XLOOKUPyou already know: ID in E2, names in A2:A6, salaries in C2:C6 IFERRORwraps it — the lookup first, the fallback second- Preferred in modern Excel:
XLOOKUP's own 4th argument (if_not_found) needs no wrapper at all
Official solutions
Show 2 solutions — try it yourself first
Approach 1: IFERROR around the lookup
=IFERROR(XLOOKUP(E2, A2:A6, C2:C6), "Not found")
The lookup returns a price when the SKU exists and #N/A when it doesn't. IFERROR converts the #N/A into "Not found" — works in every Excel version and in Google Sheets.
Approach 2: XLOOKUP's built-in if_not_found
=XLOOKUP(E2, A2:A6, C2:C6, "Not found")
The 4th argument exists exactly for this: no match → return this value. No wrapper, one function, and unlike IFERROR it can never mask unrelated errors.
Function guide
FAQ
How do I make XLOOKUP return blank instead of #N/A?
Use the 4th argument: =XLOOKUP(E2, A2:A6, C2:C6, "") returns an empty-looking cell on a miss. For a visible message use =XLOOKUP(E2, A2:A6, C2:C6, "Not found").
IFERROR or XLOOKUP's if_not_found — which should I use?
With modern Excel or Google Sheets, prefer the 4th argument: it traps only misses. IFERROR(x, y) also hides #REF!, #VALUE!, and #DIV/0! — convenient, but it can hide structural breakage a miss never would.
Does Google Sheets XLOOKUP support if_not_found?
Yes. Sheets' XLOOKUP has the same 4th argument, so =XLOOKUP(E2, A2:A6, C2:C6, "Not found") works identically. On very old Excel versions without XLOOKUP, use =IFERROR(VLOOKUP(…), "Not found") instead.