XLOOKUP Formula in Excel: Syntax, Examples, and VLOOKUP Migration
XLOOKUP formula in Excel explained: syntax, exact match, reverse lookup, and if_not_found. Real examples plus VLOOKUP migration tips for analysts daily.
The XLOOKUP formula in Excel is the lookup analysts should reach for first. It replaces the fragile column-index mechanics of VLOOKUP with two direct references — where to search, what to return — so inserting a column upstream can no longer scramble a shipped report. If you already know the VLOOKUP vs XLOOKUP tradeoffs, this post is the deep, formula-level companion: full syntax, real analyst scenarios, and a migration path for legacy files.
On the Data Analyst Roadmap, lookups sit in weeks 5–6 next to pivot tables: they are how you enrich one table with columns from another before any aggregation happens.
Column index numbers needed — XLOOKUP references arrays directly
VLOOKUP's col_index_num goes stale the moment someone inserts a column. XLOOKUP points at the return array itself, so the reference follows the data wherever it moves.
XLOOKUP Formula in Excel: Syntax and How It Works
Per Microsoft Support: XLOOKUP:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])| Argument | Required | What it does |
|---|---|---|
lookup_value | Yes | The value to find (for example A2, an employee ID) |
lookup_array | Yes | The column or row to search (for example $A$10:$A$22) |
return_array | Yes | The column(s) to return from (for example $B$10:$D$22) |
[if_not_found] | No | Value returned on no match ("Not found"); defaults to #N/A |
[match_mode] | No | 0 exact (default), -1 exact-or-next-smaller, 1 exact-or-next-larger, 2 wildcard |
[search_mode] | No | 1 first-to-last (default), -1 last-to-first, 2/-2 binary search on sorted data |
Three properties make the XLOOKUP formula in Excel fundamentally safer than VLOOKUP. First, lookup and return arrays are independent — the search column can sit anywhere, even to the right of the return column, which enables reverse lookups with zero restructuring. Second, exact match is the default, eliminating the classic VLOOKUP bug where omitting FALSE silently returns an approximate match. Third, one formula can return many columns: when return_array spans B:D, the result spills across three cells as a dynamic array.
Step-by-Step Example: Enriching an Attrition Report
HR hands you a roster in A:D (employee ID, name, department, status) and a salary master in F:H (employee ID, band, monthly CTC). You need CTC on every roster row:
| Emp ID (A) | Name | Dept | Formula in E2 (filled down) |
|---|---|---|---|
| E1042 | Sana | Support | =XLOOKUP(A2, $F$2:$F$500, $H$2:$H$500, "Missing") |
| E1043 | Dev | Sales | =XLOOKUP(A3, $F$2:$F$500, $H$2:$H$500, "Missing") |
Step 1 — write the base lookup in E2:
=XLOOKUP(A2, $F$2:$F$500, $H$2:$H$500, "Missing")Look up A2 in the master ID column, return the CTC. The fourth argument "Missing" converts unmatched IDs from #N/A into a readable flag — always pass it in production sheets so a missing master row reads as data, not as a broken formula.
Step 2 — return three columns at once for the full enrichment:
=XLOOKUP(A2, $F$2:$F$500, $G$2:$H$500, "Missing")With return_array spanning band and CTC, one formula spills both. No copying across columns, no per-column index to maintain — contrast this with the three-VLOOKUP pattern in the VLOOKUP vs XLOOKUP guide.
Step 3 — run a reverse lookup. The master stores names in column G but you need the ID from column F, which sits to the left of nothing relevant — with XLOOKUP the direction simply does not matter:
=XLOOKUP(B2, $G$2:$G$500, $F$2:$F$500, "Missing")Search names, return IDs. VLOOKUP users would have to duplicate or move columns; here the arrays are just two independent references.
Step 4 — take the last match instead of the first. If the master has one row per salary revision and you want the latest, search bottom-up:
=XLOOKUP(A2, $F$2:$F$500, $H$2:$H$500, "Missing", 0, -1)search_mode -1 scans last-to-first, so the most recent revision wins. This single argument replaces an entire MAXIFS-plus-INDEX construction.
Common Mistakes and Fixes
Spill blockage: #SPILL! on multi-column returns
=XLOOKUP(A2, $F$2:$F$500, $G$2:$H$500) needs two empty cells to its right. If column F already holds a value in the spill path, every row shows #SPILL!. The fix is layout, not syntax: put multi-column XLOOKUPs where they have room to breathe, and never place two spilling formulas side by side without a gap.
The second recurring mistake is mismatched array shapes. lookup_array with 499 rows against a return_array with 500 rows returns #VALUE! — the arrays must align row-for-row. When both columns come from the same master table this happens only after a partial delete, so treat the error as a data-hygiene alarm and check the master for a short column (the data cleaning guide covers the audit pattern).
Approximate match needs sorted data — exact is the safe default
match_mode -1 and 1 (next-smaller / next-larger, the slab-lookup modes) assume the lookup array is sorted appropriately. On unsorted data they return confidently wrong answers with no error. Unless you are deliberately building tax-slab or grade logic on a sorted column, leave match_mode at its exact default.
XLOOKUP Formula in Excel vs the Alternatives
| Feature / Criteria |
|---|
Migrate a VLOOKUP by mapping its parts: the first column of table_array becomes lookup_array, the target column becomes return_array, and the FALSE becomes unnecessary (exact is already the default):
=VLOOKUP(A2, $F$2:$H$500, 3, FALSE)becomes:
=XLOOKUP(A2, $F$2:$F$500, $H$2:$H$500, "Missing")Keep the old formula in a hidden audit column during migration week, compare the two columns with =C2=E2, and delete the legacy column only when every row matches.
When to Use the XLOOKUP Formula in Excel in Analyst Work
Master-data enrichment. Joining a transaction extract to an employee, product, or region master is the weekly bread-and-butter: one XLOOKUP column per attribute, with "Missing" flags that double as a master-completeness check. When the join key needs cleaning first (trailing spaces, mixed case), fix it with the data cleaning patterns before the lookup, not after.
Reverse and bottom-up lookups. Finding an ID from a name, or the latest revision from a history table, previously required helper columns or array gymnastics. XLOOKUP handles both natively — independent arrays for direction, search_mode -1 for recency — so these stop being special cases and become one-liners.
Report assembly with spill ranges. A single XLOOKUP returning five columns feeds a summary block that resizes itself when the master gains columns. Pair it with filter hygiene so the spill range is never inside a filtered table, and the query ran — and this time the answer is verifiably right, because there is no column index left to go stale.
Related Excel Tutorials
- Excel Formulas: The Complete Guide
- VLOOKUP vs XLOOKUP Guide
- SUM Formula in Excel
- Excel Pivot Tables Guide
- Explore All Guides in the Excel Tutorials Hub
Master Excel for Data Analysis
Learn Excel formulas, pivot tables, and dashboards with free, project-based courses.
Start Free Excel CourseFrequently Asked Questions
What is the XLOOKUP formula in Excel?
The XLOOKUP formula in Excel is =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]). It searches lookup_array for a value and returns the corresponding item from return_array, with exact match as the default.
Why is the XLOOKUP formula in Excel better than VLOOKUP?
XLOOKUP searches any column (not just the first), needs no fragile column index number, defaults to exact match, returns multiple columns in one spill, and has a built-in if_not_found argument. VLOOKUP breaks when columns are inserted; XLOOKUP does not.
How do I do a reverse lookup with the XLOOKUP formula in Excel?
Put the arrays in any order: =XLOOKUP(A2, $C$2:$C$100, $A$2:$A$100) looks up A2 in column C and returns from column A, even though A is left of C. VLOOKUP cannot do this without rearranging the table.
Why does my XLOOKUP formula in Excel return #N/A or #SPILL!?
#N/A means no match — pass a fourth argument like "Not found" to handle it gracefully. #SPILL! means cells in the spill range are blocked; clear the obstructing cells and the multi-column return will flow.
Does XLOOKUP work in older Excel versions?
XLOOKUP needs Microsoft 365 or Excel 2021+. For workbooks shared with Excel 2019 or older, keep VLOOKUP or INDEX-MATCH versions, since XLOOKUP shows as #NAME? where it is unsupported.

Written by
Founder at Topfolio with 6+ years in data & analytics across JPMC, Ultrahuman, and high-growth startups. Sat on hiring panels, reviewed 500+ resumes, and writes practical SQL & data guides.
Related Articles
VLOOKUP vs XLOOKUP in Excel: When to Use Each (with TRANSPOSE)
VLOOKUP vs XLOOKUP in Excel: compare the vlookup formula in excel against XLOOKUP, avoid column index bugs, and reshape dynamic array spills.
Excel Formulas: The Complete Guide for Data Analysts (2026)
Master essential excel formulas in this complete guide: lookup, math, dynamic arrays, text, financial modeling, and 30+ core functions for analysts.
INDEX MATCH Function in Excel: Flexible Lookups (with Examples)
INDEX MATCH function in Excel explained: =INDEX(return, MATCH(lookup, range, 0)). Left lookups, two-way matches, and XLOOKUP migration tips for analysts.