Worked exampleExcel
XLOOKUP instead of VLOOKUP: why one new column breaks a lookup
Using XLOOKUP instead of VLOOKUP prevents a silent error: in this example one column added to the price list left reported revenue at EGP 330,000 instead of 354,000.
- Written by Mahmoud Sabry
- Published
- Last updated
- Reading time 5 min read
- Checks Check lines recalculated by script Editorial policy
The problem: prices went up and reported revenue did not
An office supplies company raised its prices at the start of the month. The sales report multiplies quantity by price, and the price comes from the price list through a VLOOKUP formula. After the increase, revenue looked almost unchanged from the previous month.
No formula had been edited and there was no error message. But a new column, "old price", had been inserted in the price list before the price column. That column alone made the report read the old prices, and it is the practical case for XLOOKUP instead of VLOOKUP.
Table 1
Revenue at new prices is EGP 354,000 against 330,000 at old prices
EGP, the month's sales by quantity and price, hypothetical company
| Item | Quantity | Old price | New price | Revenue at new price |
|---|---|---|---|---|
| Paper | 500 | 110 | 120 | 60,000 |
| Pens | 1,200 | 80 | 85 | 102,000 |
| Files | 300 | 230 | 240 | 72,000 |
| Notebooks | 2,000 | 55 | 60 | 120,000 |
Source: Illustrative calculation from hypothetical data.
Why VLOOKUP breaks silently when a column is inserted
VLOOKUP searches for the code in the first column of the table, then returns the value from a column given by number. The formula used column 3, the price column. Once "old price" was inserted before it, column 3 became the old price.
The formula still works and returns sensible figures, but they are last month's. That is the most dangerous kind of spreadsheet error: one that shows no error message.
To find it quickly, pick an item whose new price you know and compare its price in the report with the price list. If they differ, check the column number in the formula and count the table's columns by hand.
Exhibit 1
The old formula gives 330,000 and the new one 354,000 from the same data
EGP, the sales sheet after the inserted column, before and after the fix
Before: =VLOOKUP([@Code],PriceList,3,FALSE)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Revenue |
| 2 | Paper | 500 | 110 | 55,000 |
| 3 | Pens | 1,200 | 80 | 96,000 |
| 4 | Files | 300 | 230 | 69,000 |
| 5 | Notebooks | 2,000 | 55 | 110,000 |
| 6 | Total | 330,000 |
After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price])
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Revenue |
| 2 | Paper | 500 | 120 | 60,000 |
| 3 | Pens | 1,200 | 85 | 102,000 |
| 4 | Files | 300 | 240 | 72,000 |
| 5 | Notebooks | 2,000 | 60 | 120,000 |
| 6 | Total | 354,000 |
Source: Illustrative calculation from hypothetical data.
View data table
| Before: =VLOOKUP([@Code],PriceList,3,FALSE) 2 | Paper | 500 | 110 | 55,000 |
|---|---|
| Before: =VLOOKUP([@Code],PriceList,3,FALSE) 3 | Pens | 1,200 | 80 | 96,000 |
| Before: =VLOOKUP([@Code],PriceList,3,FALSE) 4 | Files | 300 | 230 | 69,000 |
| Before: =VLOOKUP([@Code],PriceList,3,FALSE) 5 | Notebooks | 2,000 | 55 | 110,000 |
| Before: =VLOOKUP([@Code],PriceList,3,FALSE) 6 | Total | | | 330,000 |
| After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price]) 2 | Paper | 500 | 120 | 60,000 |
| After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price]) 3 | Pens | 1,200 | 85 | 102,000 |
| After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price]) 4 | Files | 300 | 240 | 72,000 |
| After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price]) 5 | Notebooks | 2,000 | 60 | 120,000 |
| After: =XLOOKUP([@Code],PriceList[Code],PriceList[New price]) 6 | Total | | | 354,000 |
XLOOKUP instead of VLOOKUP: point at the column by name, not number
XLOOKUP needs three inputs: what to look for, the column to search and the column to return. You select the new price column itself, so the formula stays correct however many columns are inserted.
If the price list is converted to an Excel Table, the formula reads like a sentence: find the code in the code column and return the new price.
XLOOKUP has two further advantages. Exact match is the default, so FALSE is not needed, and a fourth input sets what appears when the code is missing, so no IFERROR wrapper is needed.
When to keep the old approach: the version decides the function
- If everyone who opens the file uses Excel 2021 or later or the current subscription: use XLOOKUP.
- If the file goes to users of an older version: use INDEX with MATCH, which also points at the result column and works in every version.
- If an old file works and other departments rely on it: do not rewrite it on a closing day; add a check cell and move later, after telling its users.
Table 2
One check cell would have caught the EGP 24,000 gap
EGP, the month's revenue in the report against the correct revenue
| Item | EGP |
|---|---|
| Revenue in the report | 330,000 |
| Correct revenue | 354,000 |
| Difference | 24,000 |
Source: Illustrative calculation from hypothetical data.
Note: The whole difference is the price increase that did not reach the report.
A cell comparing the report total with total invoices in the system would have shown the gap before the report was sent. For a fuller comparison of the two functions, see our article XLOOKUP vs VLOOKUP for finance work.
Common errors
- Writing VLOOKUP without the fourth input FALSE: the search becomes approximate and, if the list is not sorted, returns another item's price. Correction: always write FALSE, or move to XLOOKUP.
- Relying on a fixed column number: the result changes when a column is inserted, as the gap of 24,000 shows. Correction: point at the result column itself.
- Hiding the error with a zero: the item drops out of revenue. Correction: return text that says the code is missing.
How to check your work
- Compare total revenue in the report with total invoices in the system; the difference must be zero.
- Pick an item with a known price and match its price in the report with the price list.
- Search the file for every VLOOKUP and confirm its fourth input is FALSE.
Limits of the method
XLOOKUP does not work in versions older than Excel 2021, where it may show an error when the file recalculates in an older version. Switching functions does not fix wrong data in the price list itself, and it does not replace a check figure that ties the report to its source.
Frequently asked questions
Should every VLOOKUP in my files be converted now?
No. Start with files that several people edit, and add a check cell to older files until they are converted.
What replaces XLOOKUP in an older version?
INDEX with MATCH, which points at the result column itself and is not affected by inserted columns.
Why was there no error message when the result was wrong?
The formula did find the code and returned a value from an existing column; it was simply the wrong column.
Does converting the list to a Table help?
Yes. The formula reads with column names, and the table extends automatically when rows are added.
Terms in this article
| English | Arabic | Meaning |
|---|---|---|
| VLOOKUP | دالة البحث العمودي | A function that returns a value from a column given by number |
| XLOOKUP | دالة البحث الحديثة | A function that returns a value from a column given by its range |
| Exact match | المطابقة التامة | A search that accepts only the same code |
Related lessons
Read next
Sources and notes
Figures and companies in the examples are illustrative and hypothetical, and do not refer to any real organisation.
Prices and revenue are in Egyptian pounds.
Educational content, not financial, tax or investment advice. Check the standards and rules in force before applying anything.
Share this article
One column added to a price list hid EGP 24,000 of revenue. When to use XLOOKUP instead of VLOOKUP: