XLOOKUP: handling missing values
Each price change is added at the bottom, so most products appear more than once. Headset is in rows 8 and 12, for example.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Week | Product | Price | Product | Latest price | ||
| 2 | Week 1 | Monitor Stand | 33.99 | Notebook A5 | |||
| 3 | Week 2 | Office Chair | 188.5 | Headset | |||
| 4 | Week 3 | Bookshelf | 151.49 | Office Chair | |||
| 5 | Week 4 | Bookshelf | 156.49 | Bookshelf | |||
| 6 | Week 5 | USB-C Hub | 35.25 | Monitor Stand | |||
| 7 | Week 6 | USB-C Hub | 41.25 | ||||
| 8 | Week 7 | Headset | 54.25 | ||||
| 9 | Week 8 | Headset | 55.25 | ||||
| 10 | Week 9 | Bookshelf | 158.49 | ||||
| 11 | Week 10 | Office Chair | 191.5 | ||||
| 12 | Week 11 | Headset | 57.25 | ||||
| 13 | Week 12 | Office Chair | 192.5 | ||||
| 14 | |||||||
| 15 | |||||||
| 16 | |||||||
| 17 |
How XLOOKUP works
What are
XLOOKUP's extra parts?After the three you know,
XLOOKUPhas three optional ones:=XLOOKUP(lookup_value,lookup_array, return_array, [if_not_found], [match_mode], [search_mode]) What does if_not_found do?
It is what to show when the value isn't there, instead of #N/A:
"Not found", a blank"", or 0. It does the job ofIFNAwithout a second function.What does match_mode do?
- 0: exact match (the default).
- -1: exact match, or the next smaller value (bands, like
VLOOKUPwithTRUE). - 1: exact match, or the next larger value.
- 2: wildcards, so "Acme*" matches anything starting with Acme.
What does search_mode do?
- 1: search from the top (the default).
XLOOKUPstops at the first match. - -1: search from the bottom up, so it finds the last match.
In a log where new rows are added at the bottom, such as price changes or stock counts, the last match is the latest one. That's something
VLOOKUPcan't do at all.- 1: search from the top (the default).
Can I skip parts in the middle?
Yes, leave them empty between commas:
=XLOOKUP(E2,B2:B13,C2:C13,,,-1). Writing 0 for match_mode makes it easier to read.
Know someone fighting with a spreadsheet? Send them this page.