The request

From Thomas Whitaker, Head of Merchandising
Your goal
Use XLOOKUP to fill D2:D20 with each line's product name and E2:E20 with its subcategory. Look up the product_id from column B in the catalog's product_id column I2:I17 (its last column) and return from G2:G17 (name) or H2:H17 (subcategory). When a product is not in the catalog, return the text "discontinued".
- Fill
D2:E20with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
XLOOKUPnot done yet
Your sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | order_item_id | product_id | quantity | product_name | subcategory | name | subcategory | product_id | ||
| 2 | 18334 | 108 | 8 | Vale Velvet Loveseat | Sofas | 101 | ||||
| 3 | 18342 | 119 | 4 | Alder Oak Coffee Table | Tables | 102 | ||||
| 4 | 18385 | 115 | 1 | Orchard Rattan Dining Chair | Chairs | 103 | ||||
| 5 | 18388 | 110 | 4 | Upland Oak Bookcase | Storage | 104 | ||||
| 6 | 18394 | 109 | 1 | Avery Leather Bed Frame | Beds | 105 | ||||
| 7 | 18419 | 109 | 1 | Birch Teak Side Table | Tables | 107 | ||||
| 8 | 18421 | 105 | 1 | Ashford Leather Dining Chair | Chairs | 108 | ||||
| 9 | 18438 | 103 | 2 | Oakley Oak Bookcase | Storage | 109 | ||||
| 10 | 18478 | 118 | 3 | Linen Velvet Headboard | Beds | 110 | ||||
| 11 | 18486 | 106 | 1 | Tidewater Teak Loveseat | Sofas | 111 | ||||
| 12 | 18501 | 101 | 1 | Vale Walnut Coffee Table | Tables | 112 | ||||
| 13 | 18514 | 108 | 1 | Bayside Rattan Dining Chair | Chairs | 113 | ||||
| 14 | 18519 | 110 | 1 | Weston Ash Bed Frame | Beds | 115 | ||||
| 15 | 18522 | 117 | 1 | Orchard Walnut Side Table | Tables | 117 | ||||
| 16 | 18529 | 111 | 1 | Willow Ash Lounge Chair | Chairs | 118 | ||||
| 17 | 18561 | 115 | 1 | Alder Linen Sideboard | Storage | 119 | ||||
| 18 | 18571 | 104 | 1 | |||||||
| 19 | 18575 | 106 | 2 | |||||||
| 20 | 18582 | 106 | 1 | |||||||
| 21 | ||||||||||
| 22 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Thomas gets, and why
The lesson
VLOOKUP has two habits you met in level 3: it only searches the first column of its table, and
it counts columns by number. Thomas’s catalog export breaks the first rule. The id is in the
last column, I, with the name and subcategory to its left in G and H. VLOOKUP can’t look
left. XLOOKUP, the modern lookup in Excel 2021, Microsoft 365 and Google Sheets, can.
Search one range, return another
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found])
| Argument | In D2 | Means |
|---|---|---|
lookup_value |
B2 |
the id to find (108) |
lookup_array |
$I$2:$I$17 |
the column to search |
return_array |
$G$2:$G$17 |
the column to bring back from |
if_not_found |
"discontinued" |
what to show when the id isn’t there |
Instead of a table and a column number, XLOOKUP takes two separate ranges. For row 2 it finds
108 on the 7th row of I2:I17 and returns the 7th value of G2:G17: Ashford Leather Dining
Chair. For the subcategory, change only the return range to $H$2:$H$17, which gives Chairs.
Which side the return range is on doesn’t matter, so a right-to-left lookup is no harder
than a left-to-right one. The two ranges must be the same height; if they aren’t, XLOOKUP shows
#VALUE!.
Exact match by default
XLOOKUP looks for exactly 108 unless you ask for something else, and it doesn’t care how the
catalog is sorted. No FALSE to remember. Its fifth argument can ask for the next smaller or
larger value instead, which suits band tables like the shipping fees in level 1, but for ids
you want the default.
A fallback built in
The catalog only lists products on sale today. Product 106 was discontinued, and it appears on
three lines (rows 11, 19 and 20). Without a fourth argument, XLOOKUP(B11,…) shows #N/A. With
"discontinued", the cell says what happened, with no IFERROR wrapped around it.
Use a fallback only when you know why keys are missing. Here the reason is clear. If dozens of
ids were missing for no reason, the honest move would be to leave the #N/A and find out why.
Lock the lookup ranges
Every row searches the same catalog, so both ranges need $. Filled down without them,
I2:I17 becomes I3:I18 on the next row, then I4:I19, and the catalog slides away one row
at a time. On this sheet that turns the line in row 8 (product 105, Avery Leather Bed Frame)
into “discontinued”, because 105 has already slid out of the search. In total, eight lines of
products still on sale end up marked discontinued.
Common mistakes
- Swapping the two ranges.
XLOOKUP(B2,$G$2:$G$17,$I$2:$I$17)searches the names for 108 and finds nothing. - Unlocked ranges. The first rows look right, lower rows report products as missing.
- A number stored as text. If the ids in one table are text (
"108"), XLOOKUP won’t match them to the number 108. Text sits on the left of the cell, numbers on the right. - Hiding a real problem. A fallback on every lookup can cover up a broken join. Count the fallbacks: here it is exactly the 3 lines of product 106.
- Expecting a spill. In Microsoft 365 and Google Sheets,
XLOOKUP(B2,$I$2:$I$17,$G$2:$H$17)returns name and subcategory at once and spills into E. This practice sheet keeps one value per cell, so write one formula per column.
Lantern lit!
Practised: xlookuplookupsif not foundabsolute references
- Solved
- No hints
- First run
