7 minute read

Good evening everyone! Tonight in my free time, I was reviewing how I join and combine tables across different tools—specifically why writing a LEFT JOIN in SQL or pd.merge() in pandas feels completely natural, while doing the exact same lookup in Excel always makes me pause and second-guess the argument order.

When you spend most of your time working with relational tables or DataFrames, you think in set-based operations: take Table A, take Table B, match them on a key column, and produce a new table in one shot. Excel flips that mental model upside down. Instead of merging two tables at once, Excel forces you to stand inside one single cell, send a formula over to another table to fetch one value, and then drag that formula down across all your rows.

SQL and pandas Bulk Merge vs Excel Cell-by-Cell Lookup

To make sure this sticks for good, I built an interactive, self-grading practice workbook using the classic Sample - Superstore dataset (Orders, People, Returns, Shipping_Table, Discount_Matrix, and Commission_Rules):

  • Open the Live Google Sheets Exercise Workbook: Excel & Sheets Lookup Mastery (Superstore) (Tip: Click File → Make a copy so you have your own private copy where the Auto-Check column turns green as you solve each prompt!)

Since I need to record a lot of stuff so I can remember it properly, here are the 5 core lookup functions, a visual decision map, and 15 hands-on exercises you can practice right inside that spreadsheet.

Excel Lookup Function Decision Map


1. VLOOKUP: Vertical Scan, Right-Only Pull 🔍

VLOOKUP stands for Vertical Lookup. It scans down the leftmost column of a table until it finds an exact match for your lookup key, then slides to the right on that same row to return a value from a specific column number.

Extra Example: Think of a printed language dictionary or a university exam roster sorted by Student ID on the far left. You run your finger down the left column until you find your ID, then slide straight across to the right to read your grade. You can never read backward to the left of the ID column.

VLOOKUP Visual Flow Diagram

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
  • lookup_value: What you are searching for (e.g., '1_Dataset'!C2, which holds "South").
  • table_array: The lookup range where your key must sit in the very first column (e.g., '1_Dataset'!$I$1:$J$5).
  • col_index_num: Which column inside that highlighted box holds your answer (1 = Region, 2 = Regional_Manager).
  • [range_lookup]: Always pass FALSE (or 0) for an exact match (SQL =). Leaving this blank defaults to TRUE (approximate match), which silently returns wrong rows on unsorted keys.
=VLOOKUP('1_Dataset'!C2, '1_Dataset'!$I$1:$J$5, 2, FALSE)

2. HLOOKUP: VLOOKUP Tipped on Its Side ↔️

HLOOKUP stands for Horizontal Lookup. Instead of scanning down a leftmost column, it scans across the very top row from left to right and drops downward by a row index number.

Extra Example: Picture a university lecture timetable where the days of the week (Monday, Tuesday, Wednesday) run across the top header row, and the course times stack downward underneath each day.

=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
=HLOOKUP('1_Dataset'!D2, '1_Dataset'!$B$14:$E$16, 2, FALSE)

3. MATCH: The 1-Based Position Finder 🧭

MATCH does not return text or prices—it only returns an integer position (1, 2, 3...) telling you where an item lives inside a single 1D row or column. In Python/pandas terms, it is the 1-indexed equivalent of list.index(key) + 1.

Extra Example: Imagine searching a library catalog computer for a textbook title. The screen does not hand you the physical book—it simply outputs “Shelf #3.”

=MATCH(lookup_value, lookup_array, [match_type])
  • lookup_array: Must be a single 1D strip (one column like $I$2:$I$5 or one row like $B$19:$E$19).
  • [match_type]: 0 for exact match; 1 for largest value $\le$ lookup_value (ascending brackets); -1 for smallest value $\ge$ lookup_value (descending brackets).
=MATCH("Central", '1_Dataset'!$I$2:$I$5, 0)

(In I2:I5, "West" is 1, "East" is 2, and "Central" is 3.)


4. INDEX + MATCH: Breaking the Left-Lookup Barrier 🧩

INDEX is the exact opposite of MATCH: you hand INDEX a grid and a (row_num, column_num) coordinate, and it returns whatever value sits at that intersection—just like df.iloc[row - 1, col - 1].

When you nest MATCH inside INDEX, MATCH finds the row coordinate dynamically while INDEX pulls the answer from any column—including columns to the left of your lookup key!

=INDEX(return_column, MATCH(lookup_value, key_column, 0))

In our People table (H1:J5), Manager_Code (H) sits to the left of Region (I). VLOOKUP fails here, whereas INDEX + MATCH handles it cleanly:

=INDEX('1_Dataset'!$H$2:$H$5, MATCH('1_Dataset'!C6, '1_Dataset'!$I$2:$I$5, 0))

Even better, if someone inserts new columns between H and I, Excel updates both range references automatically instead of breaking a hardcoded column index.


5. XLOOKUP: The Modern All-in-One Replacement 👑

Available in Excel 365, Excel 2021+, and Google Sheets, XLOOKUP replaces VLOOKUP, HLOOKUP, and basic INDEX + MATCH with a single, clean syntax. Instead of counting columns, you point independently at your search column and your answer column.

“Simplicity is about subtracting the obvious and adding the meaningful.” – John Maeda

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

Why XLOOKUP feels closest to pd.merge(..., how="left").fillna():

  1. Exact match by default: match_mode defaults to 0—no more forgetting , FALSE.
  2. Built-in null handling: The 4th argument [if_not_found] replaces #N/A cleanly without wrapping everything in IFERROR().
  3. Reverse search (search_mode = -1): Scans from bottom to top so you can grab the latest transaction for a customer or region in one step.
=XLOOKUP('1_Dataset'!A2, '1_Dataset'!$H$9:$H$11, '1_Dataset'!$I$9:$I$11, "No")

Quick Side-by-Side Comparison

Feature VLOOKUP HLOOKUP INDEX + MATCH XLOOKUP
Direction Vertical only Horizontal only Any (1D or 2D) Any (1D or 2D)
Look Left / Up? No No Yes Yes
Exact Match Default? No (FALSE required) No (FALSE required) No (0 required) Yes (0 default)
Survives Column Inserts? No No Yes Yes
Built-in Fallback? No No No Yes ([if_not_found])

6. Practice Arena: 15 Exercises on the Superstore Google Sheet 🏋️‍♂️

Open the 2_Exercises tab in the Superstore Google Sheets Workbook, make a copy to your Drive, and type your formulas into Column E. Column G will automatically verify your output!

# Focus Exercise Prompt (Referencing '1_Dataset') Expected Result
1 VLOOKUP (Right) Pull Regional_Manager for Order row 2 ('1_Dataset'!C2) from People ('1_Dataset'!$I$1:$J$5). Cassandra Brandow
2 VLOOKUP (Flag) Check if Order row 4 ('1_Dataset'!A4) appears in Returns ('1_Dataset'!$H$8:$I$11). Yes
3 HLOOKUP (Exact) Get Est_Days for Order row 3 Category ('1_Dataset'!D3) from Shipping_Table ('1_Dataset'!$B$14:$E$16). 2
4 HLOOKUP (Exact) Get Handling_Fee for Order row 5 Category ('1_Dataset'!D5) from Shipping_Table ('1_Dataset'!$B$14:$E$16). 15
5 MATCH (1D Index) Find the relative row position of "Central" inside '1_Dataset'!$I$2:$I$5. 3
6 INDEX (2D Grid) Use pure INDEX on '1_Dataset'!$H$2:$J$5 (no MATCH) to pull "Chuck Magee". Chuck Magee
7 INDEX + MATCH (Left) Look left: Get Manager_Code ('1_Dataset'!$H$2:$H$5) for Order row 6 Region ('1_Dataset'!C6). MGR-03
8 INDEX + 2 MATCHes 2D Exact: Get Discount % from '1_Dataset'!$B$20:$E$23 for Order row 4 (Region C4, Qty F4). 12%
9 XLOOKUP (Left) Rewrite #7 using XLOOKUP: Get Manager_Code for Order row 6 Region ('1_Dataset'!C6). MGR-03
10 XLOOKUP (Fallback) Check Returns ('1_Dataset'!$H$9:$I$11) for Order row 2 ('1_Dataset'!A2); return "No" if missing. No
11 XLOOKUP (Reverse) Search bottom-to-top (search_mode = -1) to find the last "West" Order_ID in '1_Dataset'!$A$2:$C$11. CA-2024-167164
12 XLOOKUP (Wildcard) Use match_mode = 2 to find Customer_Name whose Order_ID ends with "161389". Irene Maddox
13 2D Approx MATCH Get Discount % for Order row 5 (Region C5 = "West", Qty F5 = 6) using bracket match (1) on Qty headers. 10%
14 XLOOKUP (Bracket) Find South’s discount ('1_Dataset'!$B$22:$E$22) for Qty = 8 using match_mode = -1 (next smaller). 12%
15 Composite Key Join Join Order row 2 on both Region (C2) & Category (D2) against Commission_Rules ('1_Dataset'!$G$20:$I$24). 8%

Complete Formula Solutions (3_Answer_Key)

  1. =VLOOKUP('1_Dataset'!C2, '1_Dataset'!$I$1:$J$5, 2, FALSE)
  2. =VLOOKUP('1_Dataset'!A4, '1_Dataset'!$H$8:$I$11, 2, FALSE)
  3. =HLOOKUP('1_Dataset'!D3, '1_Dataset'!$B$14:$E$16, 3, FALSE)
  4. =HLOOKUP('1_Dataset'!D5, '1_Dataset'!$B$14:$E$16, 2, FALSE)
  5. =MATCH("Central", '1_Dataset'!$I$2:$I$5, 0)
  6. =INDEX('1_Dataset'!$H$2:$J$5, 2, 3)
  7. =INDEX('1_Dataset'!$H$2:$H$5, MATCH('1_Dataset'!C6, '1_Dataset'!$I$2:$I$5, 0))
  8. =INDEX('1_Dataset'!$B$20:$E$23, MATCH('1_Dataset'!C4, '1_Dataset'!$A$20:$A$23, 0), MATCH('1_Dataset'!F4, '1_Dataset'!$B$19:$E$19, 0))
  9. =XLOOKUP('1_Dataset'!C6, '1_Dataset'!$I$2:$I$5, '1_Dataset'!$H$2:$H$5)
  10. =XLOOKUP('1_Dataset'!A2, '1_Dataset'!$H$9:$H$11, '1_Dataset'!$I$9:$I$11, "No")
  11. =XLOOKUP("West", '1_Dataset'!$C$2:$C$11, '1_Dataset'!$A$2:$A$11, "None", 0, -1)
  12. =XLOOKUP("*161389", '1_Dataset'!$A$2:$A$11, '1_Dataset'!$B$2:$B$11, "Not Found", 2)
  13. =INDEX('1_Dataset'!$B$20:$E$23, MATCH('1_Dataset'!C5, '1_Dataset'!$A$20:$A$23, 0), MATCH('1_Dataset'!F5, '1_Dataset'!$B$19:$E$19, 1))
  14. =XLOOKUP(8, '1_Dataset'!$B$19:$E$19, '1_Dataset'!$B$22:$E$22, 0, -1)
  15. =ARRAYFORMULA(XLOOKUP('1_Dataset'!C2&"|"&'1_Dataset'!D2, '1_Dataset'!$G$20:$G$24&"|"&'1_Dataset'!$H$20:$H$24, '1_Dataset'!$I$20:$I$24, 0))

Conclusion: Make a Copy and Solve All 15 Rows Today

Reading syntax rules once never sticks—especially when you already have SQL and pandas at your fingertips. Open the Superstore Google Sheets Exercise, click File → Make a copy, and clear all 15 rows on the 2_Exercises tab without peeking at 3_Answer_Key. Once you master XLOOKUP and INDEX + MATCH on real data, you will never get tripped up by an Excel join again.

That’s all for today, folks! Thanks for reading. I’ll catch you in the next post.

“Tell me and I forget, teach me and I may remember, involve me and I learn.” – Benjamin Franklin

Leave a comment

No GitHub account? ✉️ Reply by email · I read every message.