Sub topic 8
XLOOKUP: lookup array, return array
This chapter covers the core form of XLOOKUP: how its arguments work, how to use it to pull assumptions into a model, and the errors you are most likely to hit. It assumes you can enter formulas, understand absolute and relative references, and know why a lookup table needs one row per key. Optional arguments such as match modes are covered in the next chapter.
What XLOOKUP does
XLOOKUP finds one key in a list and returns the value from the same position in a second list. In a financial model, this is the standard way to fetch a single assumption, such as a tax rate, a growth rate, or a payment term, by name.
The basic structure has three required arguments:
=XLOOKUP(lookup_value, lookup_array, return_array)lookup_valueis the key you are searching for. It is usually a cell reference such as$A5.lookup_arrayis the single row or column that is searched.return_arrayis the row or column that holds the answer. It must have the same number of cells as the lookup array.
The function searches the lookup array for an exact match, notes the position, and returns the item at that position in the return array. The lookup array and the return array are separate arguments, so the key column does not have to sit to the left of the answer column.
A worked example
Suppose an Assumptions sheet holds keys in column B and values in column C, in rows 3 to 12.
| Row | B (key) | C (value) |
|---|---|---|
| 3 | Tax rate | 0.25 |
| 4 | Revenue growth | 0.08 |
| 5 | Days payable | 45 |
| 6 | Discount rate | 0.10 |
A calculation sheet has the key "Revenue growth" in cell $A5. This formula retrieves its value:
=XLOOKUP($A5, Assumptions!$B$3:$B$12, Assumptions!$C$3:$C$12, "Missing assumption")The formula returns 0.08. The fourth argument is the text shown if the key is not found. It is optional, but you should always supply it in a model, as explained below.
Reading the arguments carefully
Both ranges must be the same size
The lookup and return arrays must have the same length and the same orientation. If you search B3:B12 (10 cells) and return C3:C11 (9 cells), XLOOKUP returns #VALUE!. This usually happens after someone inserts a row into one range but not the other, or edits one reference by hand.
Anchor the arrays
Copy the formula down a column of keys, and the arrays must not move. Use absolute references ($B$3:$B$12) for both arrays. Keep the lookup value mixed ($A5) so the column stays fixed while the row changes as you copy down. If you forget the dollar signs, the range slides down one row with each copy, and keys near the bottom of the list will start returning errors.
Search one list, not a block
Each array must be one row or one column. Passing a multi-column block as the lookup array is an error. A block is allowed as a return array when you want a whole row or column back, which is used in two-way lookups later in this tutorial.
Why a model prefers XLOOKUP
Compared with older approaches, XLOOKUP has three properties that suit auditable models:
- Exact match is the default. The older VLOOKUP function defaults to approximate matching unless you pass
FALSE, which can return a wrong value without any warning. XLOOKUP does not have this trap. - No column counting. VLOOKUP asks for a column number, such as
3, which breaks silently if someone inserts a column. XLOOKUP points at the return column directly, so insertions adjust the reference. - The key can be anywhere. The return column can be to the left or right of the lookup column.
The main limit is compatibility. XLOOKUP is available in Microsoft 365, Excel 2021 and later, and current Excel for the web. Excel 2019 and earlier cannot calculate it, and a workbook opened there shows #NAME?. If your model is shared with users on older versions, use INDEX with MATCH, covered in later chapters.
Duplicate keys and what XLOOKUP returns
XLOOKUP returns the first match it finds, searching from the top. If "Tax rate" appears twice in the list with different values, the formula returns the upper one and gives no sign that a second exists. This is a quiet error in a model: the number looks fine, but it may be the wrong row.
A simple guard is a count of how often the key appears:
=COUNTIF(Assumptions!$B$3:$B$12, $A5)A result of 1 means the key is present once. A result of 0 means it is missing, and a result of 2 or more means it is duplicated. A later chapter builds this into a full check layer. For now, remember that the lookup itself does not warn you.
Handling a missing key
If the key is not found and you supply no fourth argument, XLOOKUP returns #N/A. That is a reasonable failure, because errors propagate into totals and force someone to look. The risk is hiding the problem rather than raising it.
Compare two approaches:
"Missing assumption"as the fourth argument. The text appears in the cell, and any formula that uses it in arithmetic returns#VALUE!. The failure is visible and traceable to the right cell.0as the fourth argument. The model calculates without complaint, but it now treats a missing assumption as zero, such as a zero tax rate. This is the dangerous choice.
Returning text, numbers, and dates
XLOOKUP returns whatever type is stored in the return cell. If the assumption is a date, the formula returns a date serial number, so format the result cell as a date. If the assumption is a percentage, format the result as a percentage. The lookup does not carry formatting across from the source cell.
Matching keys that look the same but are not
Most failed lookups in practice come from data, not from the formula. Check these causes first:
- Trailing spaces. "Tax rate " and "Tax rate" are different keys. Clean the source with
TRIM, or fix the data at entry. - Text versus number. The key
2024stored as text does not match the number 2024. Check alignment and the cell's number format. - Different spelling. "Rev. growth" does not match "Revenue growth". Controlling the key list with data validation prevents this.
XLOOKUP is not case sensitive, so "TAX RATE" matches "Tax rate".
Using the result in a model
A lookup is normally the first step in a longer calculation. Here is a growth projection that pulls its rate by name and applies it to last year's revenue in C6:
=C6 * (1 + XLOOKUP("Revenue growth", Assumptions!$B$3:$B$12, Assumptions!$C$3:$C$12))This works, but typing the key into the formula hides an input inside the logic. A cleaner layout puts the key in its own cell, for example $A5, and references that cell. Then anyone reading the model can see which assumption each row uses without opening the formula.
Summary of rules
- Give XLOOKUP a lookup value, a lookup array, and a return array of identical size.
- Anchor both arrays with
$before copying. - Supply a clear not-found message, never a silent zero.
- Check for duplicate keys separately, because only the first match is returned.
- Confirm that everyone who opens the file has a version of Excel that supports XLOOKUP.
Exercise
A model has keys in Assumptions!B3:B12 and values in Assumptions!C3:C12. A colleague writes =XLOOKUP($A5, Assumptions!B3:B12, Assumptions!C3:C11, 0) and copies it down 20 rows. Name three problems with this formula and give a corrected version.
Show answer
First, the return array has 9 cells (C3:C11) while the lookup array has 10, so the formula returns #VALUE!. Second, both arrays are relative, so copying down shifts them and later rows search the wrong cells. Third, the not-found value 0 would hide a missing assumption as a zero. Corrected: =XLOOKUP($A5, Assumptions!$B$3:$B$12, Assumptions!$C$3:$C$12, "Missing assumption")
Exercise
The key "Tax rate" appears in rows 3 and 9 of the assumptions list, with values 0.25 and 0.21. Which value does XLOOKUP return, and which formula would reveal the problem?
Show answer
XLOOKUP returns 0.25, the first match from the top, and gives no warning. The formula =COUNTIF(Assumptions!$B$3:$B$12, $A5) returns 2, which shows the key is duplicated.