XLOOKUP vs VLOOKUP: which should you use?
XLOOKUP does everything VLOOKUP does with fewer ways to go wrong. Here's the same lookup written both ways, the five differences that matter, and when VLOOKUP is still the right call.
The answer interviewers want is =XLOOKUP(F2,$C$2:$C$5,$A$2:$A$5,"Not found"): find the ID in the staff table’s ID column and return the name from the column you need, with a fallback for an ID that isn’t there. In a file that must open in Excel 2019 or older, write the same lookup as =IFNA(INDEX($A$2:$A$5,MATCH(F2,$C$2:$C$5,0)),"Not found") (IFNA needs Excel 2013 or later; before that, use IFERROR). A plain VLOOKUP can’t answer this one, because the names sit to the left of the IDs.
“Here’s an orders sheet and a staff list. Each order only has the staff ID of the rep who took it. Add a column to the orders that shows the rep’s name, and make it work when we paste in next month’s orders.”
It sounds like a quick task, and it is, once you’ve read both tables properly. Most candidates who stumble do so because they start typing before they’ve looked at which column holds what.
The staff list is in A1:C5, the orders in E1:G4. The formula goes in G2 and is copied down to G4:
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Name | Team | Staff ID | Order | Staff ID | Rep | |
| 2 | Lena Hart | North | S-104 | O-5531 | S-117 | Omar Diaz | |
| 3 | Omar Diaz | South | S-117 | O-5532 | S-104 | Lena Hart | |
| 4 | Priya Shah | North | S-121 | O-5533 | S-140 | Not found | |
| 5 | Tom Okafor | West | S-130 |
That’s XLOOKUP. Read it out loud the way you would in the interview: “Find F2 in the staff IDs, C2 to C5, and return the matching name from A2 to A5. If it isn’t there, show Not found.” Order O-5531 was taken by S-117, Omar Diaz.
If the interviewer says the file goes to people on an older version of Excel, give the INDEX and MATCH version. MATCH finds the row of the ID in the list, and INDEX returns the name on that row:
=INDEX($A$2:$A$5,MATCH(F2,$C$2:$C$5,0)) → Omar DiazThe $ signs are what make it copy. Without them, the formula in G3 would search C3:C6, a range that starts below Lena Hart’s row, and order O-5532 would show “Not found” for a rep who is on the list:
=XLOOKUP(F3,C3:C6,A3:A6,"Not found")Not found=XLOOKUP(F3,$C$2:$C$5,$A$2:$A$5,"Not found")Lena HartVLOOKUP searches the first column of the table you give it and can only return columns to its right. Give it A2:C5 and it searches the names, so no ID is ever found:
=VLOOKUP(F2,$A$2:$C$5,1,FALSE)#N/A=XLOOKUP(F2,$C$2:$C$5,$A$2:$A$5,"Not found")Omar DiazThe old workarounds, moving the ID column to the left or building a helper column, change the client’s data to suit the formula. XLOOKUP and INDEX with MATCH take the search column and the return column separately, so neither needs it. (VLOOKUP over a table rebuilt with CHOOSE also works, but it’s harder to read and to check than either.) For the full comparison, see XLOOKUP vs VLOOKUP.
Order O-5533 has staff ID S-140, which isn’t in the list. With the fallback, G4 says so plainly:
=XLOOKUP(F4,$C$2:$C$5,$A$2:$A$5,"Not found") → Not foundThe dangerous version is a lookup that doesn’t match exactly. MATCH without its last argument assumes the IDs are sorted and returns the closest one below. S-140 isn’t there, so it returns the row of S-130, and the order is credited to Tom Okafor with no error at all:
=INDEX($A$2:$A$5,MATCH(F4,$C$2:$C$5))Tom Okafor=XLOOKUP(F4,$C$2:$C$5,$A$2:$A$5,"Not found")Not foundVLOOKUP without FALSE does the same. That’s why interviewers watch for the last argument: it’s the difference between an obvious gap and a quietly wrong commission report.
New staff, new IDs and a ticket table in place of the orders, so the formula above won’t fit as it is. We check the name your formula returns, then change the ID, including one that isn’t in the list.
Your task: In G2, return the name of the person whose ID is in F2, or the text "Not found" when that ID isn't in the staff list.
Graded live| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Name | Dept | Emp ID | Ticket | Emp ID | Owner | |
| 2 | Ana Kola | Finance | E-210 | T-901 | E-233 | ||
| 3 | Ben Ortiz | Sales | E-224 | ||||
| 4 | Chloe Park | Ops | E-233 | ||||
| 5 | Dev Patel | Sales | E-247 | ||||
| 6 | Eva Novak | Finance | E-251 |
Write the formula in the bar above, then press Check or Enter.
Search the IDs in C2:C6 and return from the names in A2:A6. Give XLOOKUP "Not found" as its fourth argument, or wrap INDEX and MATCH (with 0) in IFNA.
=XLOOKUP(F2,C2:C6,A2:A6,"Not found") Any formula that returns the same result passes.
Name the key, the column to search, the column to return and the missing case in one breath: “I’ll match on the staff ID, look it up in the ID column and return the name, exact match, with Not found for any ID that’s missing. XLOOKUP if we’re on Microsoft 365, INDEX and MATCH if the file has to work in older versions, with the ranges locked before I copy it down.” That sentence answers the follow-up questions before they come. More questions like this one: Excel interview questions.
Use XLOOKUP if the company runs Microsoft 365, and say why: exact by default, no column number to count. Then show you also know INDEX and MATCH, which works in every version. If they ask for VLOOKUP by name, write it with FALSE at the end.
Many company files are full of it, so they want to know you can read and fix one. Know its weak points: the column number, and the FALSE that makes it exact.
They give the same results for an exact lookup. XLOOKUP is one function with a built-in "not found" value; INDEX and MATCH are a pair, work in older versions, and need IFNA for a missing value.
XLOOKUP, VLOOKUP and MATCH all return the first match from the top. If the latest one matters, XLOOKUP can search from the bottom with -1 as its sixth argument, the search mode.
Guides that build on this one.
XLOOKUP does everything VLOOKUP does with fewer ways to go wrong. Here's the same lookup written both ways, the five differences that matter, and when VLOOKUP is still the right call.
#N/A means a lookup didn't find what it was looking for. Here are the six usual causes, how to spot each one on the sheet, and the fix, with a practice sheet.
Extra spaces, names in the wrong order, numbers stored as text and dates that aren't dates: the cleaning task interviewers love, solved with formulas, and a sheet that grades yours.
Practise in a live grid that grades what your formula calculates, with a specific hint when it's wrong.
Runs in your browser · Graded on your result · No install