The request

From Shirley Chen, Buyer
Your goal
In E2:E21, use INDEX and MATCH to return each line's current list price: find the product_id from column B in the catalog's product_id column I2:I21 with an exact match (match type 0), and return the price on that row of H2:H21.
- Fill
E2:E21with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
INDEXMATCHnot done yet
Your sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | order_item_id | product_id | quantity | price_paid | list_price | name | unit_price | product_id | ||
| 2 | 19100 | 128 | 2 | 54.99 | Ashford Linen Pendant Light | 349.00 | 131 | |||
| 3 | 19101 | 127 | 1 | 179.00 | Bramble Ceramic Floor Lamp | 31.99 | 121 | |||
| 4 | 19111 | 135 | 1 | 149.00 | Delancey Black Metal Wall Sconce | 54.99 | 128 | |||
| 5 | 19116 | 139 | 2 | 179.00 | Dune Black Metal Floor Lamp | 51.99 | 133 | |||
| 6 | 19122 | 133 | 1 | 48.99 | Dune Black Metal Pendant Light | 189.00 | 127 | |||
| 7 | 19137 | 132 | 2 | 189.00 | Dune Ceramic Arc Lamp | 109.00 | 129 | |||
| 8 | 19146 | 129 | 2 | 109.00 | Fairhaven Brass Wall Sconce | 189.00 | 132 | |||
| 9 | 19177 | 122 | 2 | 29.99 | Fern Rattan Desk Lamp | 379.00 | 126 | |||
| 10 | 19184 | 135 | 2 | 149.00 | Marlow Glass Wall Sconce | 349.00 | 124 | |||
| 11 | 19197 | 122 | 1 | 29.99 | Marlow Linen Floor Lamp | 219.00 | 137 | |||
| 12 | 19208 | 128 | 1 | 54.99 | Monroe Glass Desk Lamp | 29.99 | 122 | |||
| 13 | 19215 | 122 | 1 | 29.99 | Oakley Brass Table Lamp | 199.00 | 138 | |||
| 14 | 19221 | 134 | 1 | 92.99 | Pacifica Black Metal Arc Lamp | 279.00 | 125 | |||
| 15 | 19224 | 131 | 1 | 349.00 | Pacifica Black Metal Table Lamp | 409.00 | 130 | |||
| 16 | 19232 | 127 | 1 | 179.00 | Quarry Ceramic Picture Light | 329.00 | 140 | |||
| 17 | 19234 | 122 | 1 | 29.99 | Quarry Rattan Picture Light | 159.00 | 136 | |||
| 18 | 19237 | 124 | 2 | 349.00 | Ridge Ceramic Chandelier | 159.00 | 135 | |||
| 19 | 19239 | 134 | 3 | 92.99 | Rowan Ceramic Chandelier | 189.00 | 139 | |||
| 20 | 19247 | 124 | 1 | 349.00 | Sable Linen Table Lamp | 92.99 | 134 | |||
| 21 | 19249 | 128 | 12 | 54.99 | Sutton Brass Chandelier | 30.99 | 123 | |||
| 22 | ||||||||||
| 23 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Shirley gets, and why
The lesson
Before XLOOKUP, the flexible lookup was a pair of functions: INDEX and MATCH. You will find
it in almost every workbook you inherit, so it is worth knowing cold. Shirley’s catalog is the
classic case for it: sorted by name in G1:I21, with the id in the last column. VLOOKUP can’t
search it, because the ids aren’t in its first column.
MATCH finds the position
=MATCH(lookup_value, lookup_range, match_type)
MATCH doesn’t return a value from the table. It returns where the value is: its position in
the range. =MATCH(B2,$I$2:$I$21,0) looks for 128 in the catalog ids and returns 3, because 128
is the third id in I2:I21. The last argument, 0, means exact match.
INDEX picks the value at a position
=INDEX(range, position)
=INDEX($H$2:$H$21,3) returns the third price in the catalog: 54.99. Put the two together and
MATCH tells INDEX which row to read:
=INDEX($H$2:$H$21,MATCH(B2,$I$2:$I$21,0))
The search range and the return range are separate arguments, so the price column can sit left of the ids, as here, or anywhere else. The two ranges only need to start and end on the same rows.
The missing 0
MATCH has a trap in its default. Without the third argument it uses 1, an approximate
match: it assumes the ids are sorted from small to large and jumps through them (a binary
search) for the largest id that isn’t above yours. Row 4 is product 135, the Ridge Ceramic
Chandelier, 159.00. MATCH(B4,$I$2:$I$21) returns 9 instead of 17, and INDEX hands back 349.00,
another lamp’s price. No error. Fill that version down and only 3 of the 20 lines come out right,
by luck. VLOOKUP without FALSE has exactly the same trap. Write the 0 every time you look up
an id, a name or a code.
VLOOKUP, INDEX/MATCH and XLOOKUP side by side
| VLOOKUP | INDEX/MATCH | XLOOKUP | |
|---|---|---|---|
| Direction | key must be the first column, returns to the right | any direction | any direction |
| Return column | a number (4) |
a range | a range |
| A column inserted in the table | the number now points at the wrong column | still right | still right |
| Default match | approximate: write FALSE |
approximate: write 0 |
exact |
| Key not found | #N/A, wrap in IFNA |
#N/A, wrap in IFNA |
if_not_found argument |
| Where it works | everywhere | everywhere | Excel 2021, Microsoft 365, Google Sheets |
The inserted-column row is the quiet one. In level 3, VLOOKUP(…,4,FALSE) returned the price
because the price was the 4th column of F:I. Insert a “supplier” column inside the catalog and
column 4 becomes the category, with no error. INDEX and MATCH point at the price column
itself, so Excel adjusts their ranges when columns move. On this sheet, the XLOOKUP version is
=XLOOKUP(B4,$I$2:$I$21,$H$2:$H$21), which also gives 159.00.
Use XLOOKUP when everyone who opens the file has it; INDEX/MATCH when the file must work in older
Excel; VLOOKUP with FALSE when the key is already the first column and you want the formula a
colleague can read at a glance.
Common mistakes
- No
0in MATCH. The lookup works on a sorted table and quietly fails on an unsorted one. - Unlocked ranges. The catalog has to stay put when you fill down:
$H$2:$H$21,$I$2:$I$21. - Ranges that don’t line up.
MATCHoverI2:I21withINDEXoverH3:H22returns the price from the row below every match. - INDEX and MATCH swapped.
MATCHgets the id column,INDEXgets the column you want back.
Lantern lit!
Practised: index matchmatchexact matchlookupsvlookup
- Solved
- No hints
- First run
