1. Lighthouse

Level 3 · List prices with VLOOKUP and IFERROR

The request

From Mei Morgan, Buyer

“I buy Decor and Textiles. For these early-February lines, can you add today's list price and the category from the catalog on the right? We've dropped a few products since, so those should say "not in catalog" rather than show an error.”

Your goal

In C2:C33, use VLOOKUP with an exact match (FALSE) to return each line's list price, the 4th column of the catalog F2:I36, looking up the product_id in column B. In D2:D33, return the category, the catalog's 3rd column, the same way. Wrap both in IFERROR so a product that isn't in the catalog shows the text "not in catalog".

  • Fill C2:D33 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use VLOOKUPnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGHIJ
1order_item_idproduct_idlist_pricecategory product_id namecategory unit_price
219128190161Cove Jute Duvet CoverTextiles219.00
319129190162Oakley Jute Knit ThrowTextiles23.99
419130162164Cove Wool Lumbar PillowTextiles52.99
519132189165Weston Cashmere-Blend QuiltTextiles25.99
619134194166Harbor Wool Knit ThrowTextiles28.99
719135185168Upland Percale Lumbar PillowTextiles159.00
819138186169Spruce Wool Duvet CoverTextiles66.99
919140173170Rowan Cashmere-Blend Throw BlanketTextiles17.99
1019141194171Driftwood Percale Area RugTextiles27.99
1119142183172Maple Wool Throw PillowTextiles18.99
1219143186173Bramble Percale QuiltTextiles139.00
1319148193174Vale Cashmere-Blend Knit ThrowTextiles18.99
1419149178175Glen Cotton Runner RugTextiles84.99
1519150186176Fairhaven Cotton Throw PillowTextiles78.99
1619152175177Delancey Cashmere-Blend Duvet CoverTextiles169.00
1719154198178Sutton Wool Knit ThrowTextiles70.99
1819156199179Delancey Jute Area RugTextiles30.99
1919157173180Hazel Linen Throw PillowTextiles20.99
2019158190181Cedar Marble Bud VaseDecor179.00
2119159193182Nantucket Brass Wall MirrorDecor17.99
2219160198184Thatcher Oak CandleDecor17.99
2319164194185Ridge Brass Bud VaseDecor12.99
2419166164186Birch Brass Floor MirrorDecor20.99
2519168193187Ashford Oak Canvas PrintDecor149.00
2619170178188Fern Oak Candle Holder SetDecor179.00
2719171163189Northfield Brass Bud VaseDecor76.99
2819173171190Elm Brass Floor MirrorDecor43.99
2919175184192Thatcher Marble Candle Holder SetDecor15.99
3019176191193Delancey Brass VaseDecor19.99
3119178166194Chester Brass Wall MirrorDecor159.00
3219179186195Fairhaven Soy Wax Framed PrintDecor103.99
3319181191196Pine Glass Candle Holder SetDecor25.99
34197Ridge Soy Wax VaseDecor109.00
35198Harbor Oak Floor MirrorDecor44.99
36199Oakley Brass Framed PrintDecor104.99
37
38

Loading the editor…

    ResultPress Check to compare C2:D33

    Mote checks your result

    Press Check. Each right cell becomes a firefly in your lantern.

    The lesson

    Order lines store a product_id, not a price or a category: those live once, in the catalog. To see them next to each line you look them up: find the line’s id in the catalog and bring back a value from the same row. VLOOKUP is the oldest way to do it, and the one you will meet most in shared workbooks. In this sheet the lines are in A1:D33 and the Decor and Textiles catalog sits on the right in F1:I36.

    The four arguments

    =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
    Argument In C2 Means
    lookup_value B2 the id to find (190)
    table_array $F$2:$I$36 the whole catalog; the ids must be in its first column
    col_index_num 4 which column of the table to return, counting from F as 1
    range_lookup FALSE exact match only

    For row 2, VLOOKUP finds 190 in column F and returns the 4th column of that row: 43.99. Change the 4 to a 3 and the same formula returns the category, Decor. The column number counts inside the table, not across the sheet: F is 1, G is 2, H is 3, I is 4. Ask for column 5 and VLOOKUP shows #REF!, because this table has only four.

    Always write FALSE

    The last argument is optional, and its default is TRUE: an approximate match. VLOOKUP then assumes the ids are sorted and settles for the largest id that isn’t above the one you asked for. On this catalog, sorted by id, that sounds harmless until a key is missing. Product 183 was dropped, and =VLOOKUP(183,$F$2:$I$36,4) returns 17.99, the price of product 182, the Nantucket Brass Wall Mirror. No error, just a wrong price. With FALSE, the same formula shows #N/A, which is the truth: 183 isn’t in the catalog.

    IFERROR for ids that aren’t there

    Four lines in this sheet are for dropped products: 183 (row 11), 163 (row 27) and 191 (rows 30 and 33). Each shows #N/A. IFERROR replaces an error with a value you choose:

    =IFERROR(VLOOKUP(B2,$F$2:$I$36,4,FALSE),"not in catalog")

    If the lookup works, IFERROR passes its result through; if it fails, the cell says “not in catalog”. Filled down, 19 lines come back as Decor, 9 as Textiles and 4 as not in catalog: 32, one per line.

    IFNA does the same but only for #N/A. That difference matters: with a wrong column number, IFERROR(VLOOKUP(B2,$F$2:$I$36,5,FALSE),…) hides the #REF! and calls a real product “not in catalog”, while IFNA lets the #REF! show so you can fix the formula. Both behave the same in Google Sheets. Text is also safer than 0 as the fallback in a price column: a 0 gets added into totals, text doesn’t.

    Common mistakes

    • No FALSE. Missing ids silently borrow the price of their neighbour.
    • Counting columns from A. The price is column 4 of F2:I36, not column 9 of the sheet.
    • Unlocked table. F2:I36 filled down becomes F3:I37, and the first products drop out of the search one row at a time. Lock it: $F$2:$I$36.
    • A table that starts at the wrong column. VLOOKUP only searches the first column of the table you give it. $G$2:$I$36 searches names, not ids.

    Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.