XLOOKUP in Numbers: A Better VLOOKUP, Step by Step
The examples use this table.
| A | B | C | |
|---|---|---|---|
| 1 | Product | Price | Qty |
| 2 | Apple | 4 | 10 |
| 3 | Pear | 6 | 5 |
| 4 | Kiwi | 12 | 2 |
| 5 | Grape | 8 | 3 |
The basic lookup
XLOOKUP takes three things: what to search for, the range to search in, and the range to take the answer from. Both ranges must have the same size. Here it looks up Kiwi in the product names and returns the price from the same row.
=XLOOKUP("Kiwi",A2:A5,B2:B5)Result: 12
Looking to the left
VLOOKUP can only return a column to the right of the search column. XLOOKUP does not care where the return range is, so you can search the prices and return the product name.
=XLOOKUP(12,B2:B5,A2:A5)Result: Kiwi
Choose what happens when nothing is found
If the value does not exist, XLOOKUP gives an error. The fourth argument lets you show your own text instead, which is cleaner than wrapping the formula in IFERROR.
=XLOOKUP("Mango",A2:A5,B2:B5,"Not found")Result: Not found
Find the position with XMATCH
If you only need to know where a value sits in a list, XMATCH returns its position. Kiwi is the third product.
=XMATCH("Kiwi",A2:A5)Result: 3
XLOOKUP or VLOOKUP?
Use XLOOKUP for new work: you do not count columns, you can look in any direction and you get a built-in way to handle missing values. VLOOKUP is still useful when you share a file with someone on an older app. The same lookup in VLOOKUP needs the column number 2.
=VLOOKUP("Kiwi",A2:B5,2,0)Result: 12
Frequently asked questions
What is the difference between XLOOKUP and VLOOKUP in Numbers?
XLOOKUP uses separate search and return ranges, can look to the left and has an argument for missing values. VLOOKUP needs a column number and only looks to the right.
How do I avoid an error when XLOOKUP finds nothing?
Add a fourth argument with the text you want to show, for example =XLOOKUP("Mango",A2:A5,B2:B5,"Not found").
Does Numbers have XLOOKUP?
Yes. XLOOKUP is available in current versions of Numbers on Mac, iPad, iPhone and iCloud.
Functions in this article
Practise it yourself
Type the formula yourself in a real exercise and see right away if your answer is correct. The first exercises are free.
Start practising