The XLOOKUP Excel function finds a value in one column and returns the matching value from any other column, left or right, with exact match as the default. Pair it with FILTER to pull every matching row and SORT to order the result, and you can retire most VLOOKUP formulas. All three need Excel 2021 or Microsoft 365.
Last updated: November 2026
Key takeaways
- XLOOKUP uses the syntax =XLOOKUP(lookup_value, lookup_array, return_array), defaults to exact match and can look to the left of the key column, which VLOOKUP cannot do.
- FILTER returns every row that meets a condition, while XLOOKUP returns only one match, so use FILTER whenever you expect several results.
- SORT and SORTBY order a spilled result with one formula, so =SORT(FILTER(…),4,-1) gives a live, descending top list.
- All three functions need Excel 2021, Excel 2024, Microsoft 365 or Excel for the web. Excel 2016 and 2019 do not have them.
- If you would rather start from a finished workbook, the Sales Commission Dashboard in Excel costs $17.99 and the Invoice Management System V1.0 costs $6.99.
Launch offerSUMIFS, XLOOKUP, FILTER, LAMBDA and checking AI-written formulas, with real business projects. 11h 47m of video by PK, with practice files, quizzes and a capstone.
XLOOKUP, FILTER and SORT tutorial: related Excel templates compared
This is a formula tutorial, but lookup formulas are usually a means to an end: commissions, invoices, pipelines. The table lists ready-made Excel files from our catalog for the same jobs, with prices.
| Template | Format | Best For | Price |
|---|---|---|---|
| Sales Commission Dashboard in Excel (best overall) | Excel, no macros | Commission tracking, quota attainment, payouts | $17.99 |
| Regional Sales Analysis Dashboard in Excel | Excel, no macros | Sales vs target by region, product and rep | $17.99 |
| CRM and Sales Pipeline Management System V1.0 in Excel VBA | Excel VBA | Deals, quotations and a sales desk in one file | $29.00 |
| Invoice Management System V1.0 (best value) | Excel VBA | Creating, tracking and PDF-saving invoices | $6.99 |
| Automatic Invoice Creator V1.0 in Excel VBA | Excel VBA | Fast invoices with taxes and due dates | $6.99 |
How we picked these
We searched the Next Gen Templates catalog for paid Excel files where lookups, filtering and sorting do the daily work: sales records, commissions, invoices and pipelines. We kept products that clearly fit those jobs and left out free files and loosely related items. The formulas in this tutorial are standard Excel and are not taken from any of these products, so treat the templates as optional next steps.
What is the XLOOKUP Excel function and how do you use it?
XLOOKUP searches a range for a value and returns the matching item from a second range. Microsoft introduced it to replace VLOOKUP, HLOOKUP and many INDEX MATCH combinations. The official reference is on Microsoft Support.
The full syntax has six arguments, three required and three optional:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
| Argument | What it does | Values |
|---|---|---|
| lookup_value | The value you are searching for | A cell, text or number |
| lookup_array | The single column or row to search | One range only |
| return_array | The range that holds the answer | Same height or width as lookup_array |
| if_not_found | What to show when nothing matches | Text, 0 or a formula |
| match_mode | How strict the match is | 0 exact (default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard |
| search_mode | Which direction to search | 1 first to last (default), -1 last to first, 2 binary ascending, -2 binary descending |
Compare that with VLOOKUP, which is =VLOOKUP(value, table, column_number, [range_lookup]). VLOOKUP counts columns by number, so inserting a column silently breaks it. It also defaults to approximate match, which returns wrong answers on unsorted data without any warning. XLOOKUP points at the return column directly and defaults to exact match.
For a three-way comparison that includes INDEX MATCH, read our INDEX MATCH vs VLOOKUP vs XLOOKUP guide with HR tracker examples. This post concentrates on how to write the formulas and how to combine them with FILTER and SORT.
Which Excel versions support XLOOKUP, FILTER and SORT?
XLOOKUP, FILTER, SORT, SORTBY and UNIQUE are available in Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. They are not in Excel 2016 or Excel 2019. If you open a workbook that uses them in an older version, the cells show a #NAME? error or the formula appears with an _xlfn prefix.
FILTER, SORT, SORTBY and UNIQUE are dynamic array functions. You type one formula in one cell and the result spills into the cells below or beside it. If you share files with colleagues on Excel 2016, use INDEX MATCH instead, or agree to upgrade first.
How do you write an XLOOKUP formula step by step?
Use a small table to follow along. Put these headings in A1:D1: Order ID, Rep, Region, Amount. Enter around 20 rows beneath them and convert the range to a table with Ctrl+T, then name it tblSales.
Step 1: Pick the cell that holds the key
Choose a clean cell, such as F2, where you type an Order ID. XLOOKUP matches exactly, so the ID must be identical to what is in the table, including its data type. A number stored as text will not match a real number.
Step 2: Write the basic lookup
In G2 enter =XLOOKUP(F2, tblSales[Order ID], tblSales[Rep]). Excel finds the Order ID in F2 and returns the rep from the same row. Because you point at the Rep column directly, you never count columns.
Step 3: Add a friendly not-found message
Extend it to =XLOOKUP(F2, tblSales[Order ID], tblSales[Rep], "Not found"). The fourth argument replaces the #N/A error, so you no longer need to wrap the formula in IFERROR. IFERROR also hides unrelated errors, which is why the built-in argument is safer.
Step 4: Return several columns at once
Make the return array wider: =XLOOKUP(F2, tblSales[Order ID], tblSales[[Rep]:[Amount]]). The formula spills Rep, Region and Amount into three cells. Keep the cells to the right empty, or Excel shows #SPILL!.
Step 5: Look to the left
Suppose you know the rep and want the Order ID, which sits in the column left of Rep. Use =XLOOKUP("Priya", tblSales[Rep], tblSales[Order ID]). VLOOKUP cannot do this without helper columns or a CHOOSE trick.
Step 6: Get the last match instead of the first
If a customer appears many times and you need the latest row, set search_mode to -1: =XLOOKUP(F2, tblSales[Rep], tblSales[Amount], "None", 0, -1). Excel searches from the bottom up and returns the most recent amount for that rep.
Step 7: Use wildcards for partial matches
Set match_mode to 2 and use * or ? in the search value: =XLOOKUP("Nor*", tblSales[Region], tblSales[Amount], "None", 2) returns the first region that starts with Nor. Wildcards only work with mode 2.
Worked example: how do you look up a commission rate with XLOOKUP?
Tiered rates are the classic approximate-match job. Build a rate table named tblRates with a Min Sales column and a Rate column:
| Min Sales | Rate |
|---|---|
| 0 | 2% |
| 10,000 | 3% |
| 25,000 | 4% |
| 50,000 | 5% |
For a rep with sales in B2, the rate formula is =XLOOKUP(B2, tblRates[Min Sales], tblRates[Rate], 0, -1). Match mode -1 returns an exact match or the next smaller value, so it lands on the correct tier. Commission is then =B2*XLOOKUP(B2, tblRates[Min Sales], tblRates[Rate], 0, -1).
| Rep sales | Tier hit | Rate | Commission |
|---|---|---|---|
| 8,200 | 0 | 2% | 164 |
| 31,500 | 25,000 | 4% | 1,260 |
| 52,000 | 50,000 | 5% | 2,600 |
VLOOKUP can do the same with its fourth argument set to TRUE, but only if the rate table is sorted ascending and the column number stays correct. XLOOKUP with mode -1 does not require sorted data.
How does the FILTER function work in Excel?
FILTER returns every row that passes a test. The syntax is =FILTER(array, include, [if_empty]). The include argument is a TRUE/FALSE array the same height as the data.
Single condition
To list every West sale, enter =FILTER(tblSales, tblSales[Region]="West", "No sales"). All four columns spill into a block, and the block resizes when the data changes.
AND logic: multiply conditions
West sales of 10,000 or more: =FILTER(tblSales, (tblSales[Region]="West")*(tblSales[Amount]>=10000), "No sales"). Multiplying two arrays gives 1 only where both are TRUE.
OR logic: add conditions
West or North sales: =FILTER(tblSales, (tblSales[Region]="West")+(tblSales[Region]="North"), "No sales"). Adding gives a value above 0 when either test is TRUE.
Return only some columns
Wrap the output in CHOOSECOLS in Microsoft 365, or point the array argument at only the columns you want, such as tblSales[[Rep]:[Amount]]. Keep the include array the same height as the array you filter.
When should you use FILTER instead of XLOOKUP?
Use XLOOKUP when you want one answer per key, such as the rate for one rep. Use FILTER when you want all rows that meet a rule, such as every sale above 10,000. XLOOKUP stops at the first match, and FILTER does not.
How do SORT and SORTBY work with FILTER?
SORT takes an array and orders it. The syntax is =SORT(array, [sort_index], [sort_order], [by_col]). Sort order 1 is ascending and -1 is descending. The sort index is the column number inside the array you pass in.
To list West sales from largest to smallest, nest FILTER inside SORT: =SORT(FILTER(tblSales, tblSales[Region]="West"), 4, -1). Column 4 is Amount. When a new West sale is added to the table, the list reorders itself.
SORTBY sorts by a column that is not part of the returned array, and it takes several keys: =SORTBY(tblSales, tblSales[Region], 1, tblSales[Amount], -1) orders by region A to Z, then by amount high to low inside each region. SORTBY refers to columns by range, so you do not have to count positions.
For a top 5 in Microsoft 365, wrap the result in TAKE: =TAKE(SORT(tblSales, 4, -1), 5). In Excel 2021 you can use INDEX with a sequence instead.
How do you combine XLOOKUP, FILTER and SORT in one sheet?
A common layout is a small report page with a dropdown and two outputs. Put a region dropdown in B1 using Data Validation. Then build:
- Total for the region:
=SUM(FILTER(tblSales[Amount], tblSales[Region]=B1, 0)) - Ranked list for the region:
=SORT(FILTER(tblSales, tblSales[Region]=B1, "No sales"), 4, -1) - Best rep name:
=XLOOKUP(MAX(FILTER(tblSales[Amount], tblSales[Region]=B1)), tblSales[Amount], tblSales[Rep])
Pick another region in B1 and all three outputs change. This single page replaces a stack of helper columns and manual sorting. Be aware that the best-rep formula returns the first rep if two share the same top amount.
Two-way lookups and nested XLOOKUP
To find a value at the crossing of a row and a column, nest one XLOOKUP in another: =XLOOKUP("Priya", A2:A10, XLOOKUP("Mar", B1:M1, B2:M10)). The inner formula picks the month column. The outer formula picks the rep row within it. This replaces the INDEX MATCH MATCH pattern.
If you move large lookups into Power Query instead, you merge tables rather than write formulas. That approach suits data that is refreshed from files or databases. For on-sheet answers that update as you type, XLOOKUP is quicker.
What are the most common XLOOKUP and FILTER errors?
| Error | Usual cause | Fix |
|---|---|---|
| #N/A from XLOOKUP | No match, often a trailing space or a number stored as text | Use TRIM on the key, convert text to numbers, add an if_not_found value |
| #VALUE! from XLOOKUP | lookup_array and return_array have different sizes | Make both ranges the same height, or the same width for rows |
| #SPILL! | Something blocks the cells where the result wants to spread | Clear the cells in the way, or move the formula |
| #CALC! from FILTER | No rows match and no if_empty value is set | Add a third argument such as “No results” |
| #NAME? | Older Excel version, or a mistyped function name | Check the version, then the spelling |
| Wrong rate returned | match_mode left at 0 on a tier table | Use -1 for the next smaller value |
| FILTER returns wrong rows | Include array is a different height than the data | Select identical row ranges for both arguments |
Should you replace every VLOOKUP with XLOOKUP?
Not automatically. Replace VLOOKUP when the workbook is used only on Excel 2021, 2024 or Microsoft 365, and when you are already editing the formula. Leave working VLOOKUPs alone in files shared with older versions. For a single lookup, XLOOKUP calculates at about the same speed. On very large lists, a sorted range with binary search mode (2 or -2) is faster than a linear search.
Which ready-made Excel templates use these skills?
If you work with sales and invoice data every week, building the whole workbook yourself takes hours. These Excel files cover the same jobs. They are not XLOOKUP templates as such, and we do not claim they contain the formulas shown above.
1. Sales Commission Dashboard in Excel: best overall
This is the finished version of the commission worked example above. It has five pages (Overview, Commission Trend, Sales Reps, Teams, Payouts), KPI cards for total sales, commission expense and effective commission rate, plus quota attainment, accelerators, SPIFFs and clawbacks. Five slicers filter every page. The Data tab holds 500 sample deals, and you add yours and click Refresh All. It runs without macros on desktop Excel for Windows (Excel 2016 or later, or Microsoft 365) and does not connect live to a CRM or payroll system.
Price: $17.99. Get the Sales Commission Dashboard in Excel.
Best for: managers who calculate monthly commissions and want to check payouts before a run.
2. Regional Sales Analysis Dashboard in Excel
It turns a list of sales records into five pages: Overview, Regions, Products, Sales Team and Customers. KPI cards cover total sales, total profit, sales target, total orders and average order value, and six slicers filter all pages. The Data tab has 500 sample sales records with formula columns for target variance and target met. It is the kind of result you would otherwise assemble from FILTER and SORT views.
Price: $17.99. See the Regional Sales Analysis Dashboard in Excel.
Best for: sales leads comparing regions, products and salespeople against targets.
3. CRM and Sales Pipeline Management System V1.0 in Excel VBA
A macro-enabled file with 16 worksheets, 12 VBA entry forms, 4 pivot dashboards and a live Profit and Loss statement. The pipeline has 6 stages, and the stage sets deal status and win probability by formula. Sample data includes 120 deals and 80 quotations. A 7-day free trial is offered before you buy.
Price: $29.00. Try the Excel CRM and sales pipeline system.
Best for: a small sales desk that has outgrown one row per deal.
4. Invoice Management System V1.0: best value
An Excel VBA tool for creating, editing, deleting and tracking invoices from one form. It fills in the invoice number and date, calculates totals, item prices and tax values, and prints or saves invoices as PDF. Item Master and Sales sheets keep the records organised.
Price: $6.99. Get the Invoice Management System in Excel VBA.
Best for: freelancers and small businesses that want an invoice database without invoicing software.
5. Automatic Invoice Creator V1.0 in Excel VBA
Enter minimal details, click a button, and the invoice is built with taxes, totals and due dates calculated. It has customizable templates for your logo and branding, multi-currency support, and invoice tracking for payments and outstanding amounts.
Price: $6.99. Get the Automatic Invoice Creator in Excel VBA.
Best for: anyone who issues invoices in several currencies and wants due dates set automatically.
How do you choose between XLOOKUP, FILTER, SORT and a template?
- Need one value for one key: use XLOOKUP.
- Need every row that meets a rule: use FILTER.
- Need the result ordered: wrap it in SORT, or use SORTBY for a hidden sort column.
- Need a tier or band lookup: XLOOKUP with match mode -1.
- Need the whole workflow, with forms, printing and dashboards: buy a finished template, such as the sales commission tracker in Excel, rather than building it.
When are these formulas NOT the right answer?
Dynamic array formulas are a poor fit when colleagues use Excel 2016 or 2019, because they will see errors. They also struggle with very large or messy data pulled from several sources. In that case, clean it with Power Query first, or move it into a database. A filtered list of 500,000 rows recalculates slowly.
If you need multiple users, permissions and barcode scanning, a spreadsheet is the wrong tool. A web app such as the Warehouse Inventory Management System Web App ($39.99) has 7 roles and 41 permissions and stores its data in a Google Sheet in your own Drive. Formulas in a shared workbook are easy to overwrite by accident, so lock formula cells or use a form.
Finally, if you only look up values once a month, a simple Ctrl+F is enough.
Frequently asked questions
What is XLOOKUP in Excel?
XLOOKUP is an Excel function that searches one range for a value and returns the matching item from another range. It defaults to exact match, can look left or right, and has a built-in not-found argument. It is available in Excel 2021, Excel 2024, Microsoft 365 and Excel for the web.
Is XLOOKUP better than VLOOKUP?
For most jobs, yes. XLOOKUP does not need a column number, so inserting columns does not break it. It matches exactly by default, can search right to left and has a not-found argument. VLOOKUP is still needed when files must open in Excel 2016 or 2019.
How do you use XLOOKUP with multiple criteria?
Join the criteria with an ampersand inside the formula, for example =XLOOKUP(F2&G2, tblSales[Rep]&tblSales[Region], tblSales[Amount]). Excel builds a combined key in memory and matches against it. For several matching rows rather than one, use FILTER with multiplied conditions instead.
Why does my XLOOKUP return #N/A?
Usually the value is not in the lookup range exactly as typed. Check for trailing spaces, a number stored as text, or different spelling. Wrap the key in TRIM, convert text numbers, or add a fourth argument such as “Not found” so the cell shows a message instead of an error.
What does the FILTER function do in Excel?
FILTER returns all rows from a range that meet a condition you set. The syntax is =FILTER(array, include, [if_empty]). The results spill into neighbouring cells and update when the source data changes. It needs Excel 2021, Excel 2024 or Microsoft 365, and shows #CALC! if nothing matches and no if_empty is given.
How do you sort and filter at the same time in Excel?
Nest FILTER inside SORT: =SORT(FILTER(tblSales, tblSales[Region]=”West”), 4, -1). FILTER picks the rows, and SORT orders them by column 4 in descending order. The list updates automatically when the table changes. SORTBY works the same way but sorts by a column you reference directly.
Does XLOOKUP work in Excel 2016 or 2019?
No. XLOOKUP, FILTER, SORT, SORTBY and UNIQUE are not in Excel 2016 or Excel 2019. They are in Excel 2021, Excel 2024, Microsoft 365 and Excel for the web. In older versions you will see #NAME?, so use INDEX MATCH there.
Can XLOOKUP return more than one column?
Yes. Make the return_array span several columns, such as tblSales[[Rep]:[Amount]], and the result spills across those columns in one row. Leave the cells to the right empty or Excel shows #SPILL!. Use FILTER instead if you need several rows.
How do you find the last matching value with XLOOKUP?
Set the sixth argument, search_mode, to -1. For example =XLOOKUP(F2, tblSales[Rep], tblSales[Amount], “None”, 0, -1) searches from the bottom of the list upward and returns the latest entry for that rep. The default value 1 returns the first match.
Get more Excel templates
If you would rather open a finished workbook than write formulas, start with the Sales Commission Dashboard in Excel at $17.99, or the Invoice Management System V1.0 at $6.99. Our step-by-step videos are on the Next Gen Templates YouTube channel.






