Why lookups?#
Data usually lives in several tables. The Sales sheet has the product, but the cost price is in the Products sheet and the target is in the Targets sheet. Lookups bring that information together - like joins in SQL.
Lookup = एक table से दूसरी table में जानकारी ढूँढकर लाना।
जैसे Sales sheet में product का नाम है, लेकिन उसकी cost price Products sheet में है। VLOOKUP / XLOOKUP से हम product के नाम से Products sheet में ढूँढकर cost price ले आते हैं - जैसे किसी register में नाम ढूँढकर उसके आगे लिखा मोबाइल नंबर पढ़ना।
VLOOKUP#
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
| Argument | Meaning |
|---|---|
lookup_value |
what to search for (e.g. the product name in J2) |
table_array |
where to search - the first column must contain the lookup values |
col_index_num |
which column of that range to return (1 = first) |
range_lookup |
FALSE = exact match, TRUE = approximate |
Get the cost price of each product (Products sheet: A = product, E = cost_price):
=VLOOKUP(J2, Products!$A$2:$E$21, 5, FALSE)
VLOOKUP's limitations#
- Looks only in the first column and returns columns to the right.
- A column number breaks if someone inserts a column.
- Returns
#N/Aif not found - you must wrap it in IFERROR. - Approximate match is the default if you forget the last argument - a classic silent bug.
XLOOKUP (Excel 2021 / 365, Google Sheets)#
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Same cost-price lookup:
=XLOOKUP(J2, Products!$A$2:$A$21, Products!$E$2:$E$21, "Not found")
With Tables (cleaner):
=XLOOKUP([@product], tblProducts[product], tblProducts[cost_price], "Not found")
Advantages:
- Lookup and return columns are chosen separately - left lookups work.
- Exact match by default.
- Built-in if_not_found text.
- Can return several columns at once:
=XLOOKUP(J2, tblProducts[product], tblProducts[[category]:[cost_price]]). - Can search from the last match:
search_mode = -1(e.g. latest price).
If your colleagues use older Excel (2016/2019), use INDEX-MATCH or VLOOKUP so the file works for everyone.
INDEX-MATCH#
Works in every Excel version and has none of VLOOKUP's limitations:
=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
=INDEX(Products!$E$2:$E$21, MATCH(J2, Products!$A$2:$A$21, 0))
MATCH(J2, Products!A2:A21, 0)→ the position of the product in the list (e.g. 9).INDEX(Products!E2:E21, 9)→ the 9th value in the cost column.
Two-way lookup (row and column)#
Find the value at the intersection of a region (row) and a month (column) in a summary grid:
=INDEX($B$2:$M$6, MATCH("West", $A$2:$A$6, 0), MATCH("Oct", $B$1:$M$1, 0))
With XLOOKUP, nest one inside another:
=XLOOKUP("West", A2:A6, XLOOKUP("Oct", B1:M1, B2:M6))
Approximate match - slabs and bands#
A commission table sorted ascending by the slab start:
| A (From sales) | B (Commission %) | |
|---|---|---|
| 2 | 0 | 2% |
| 3 | 50000 | 3% |
| 4 | 100000 | 5% |
=VLOOKUP(N2, $A$2:$B$4, 2, TRUE) → finds the largest "From" ≤ N2
=XLOOKUP(N2, $A$2:$A$4, $B$2:$B$4, , -1) → match_mode -1: exact or next smaller
For a salesperson with sales of 72,000 → 3%. Same idea for grades, tax slabs, discount tiers and age bands.
Fixing #N/A#
| Cause | Fix |
|---|---|
Extra spaces ("Indore ") |
TRIM both sides, or clean the data |
Number vs text (101 vs "101") |
convert with VALUE or TEXT so both match |
Spelling differences (Bangalore / Bengaluru) |
standardise with a mapping table |
| Value genuinely missing | IFERROR(..., "Not found") or XLOOKUP's if_not_found |
| Range not locked, shifted when copied | use $ or Tables |
Don't hide every #N/A with IFERROR immediately. First find out why it's missing - it often reveals a data quality problem you need to fix.
Practice#
- In the Sales table, add
cost_price_unit= XLOOKUP of product → Products[cost_price]. - Add
target_2025to a region summary using the Targets sheet, and calculate achievement %. - In the cleaned Raw_Data sheet, fill the 10 blank regions using a city → region lookup (build the city-region list with
=UNIQUE(tblSales[[region]:[city]])or a pivot).
1. What is the unit cost price of "Green Soul Ergonomic Chair" and "HP 15 Laptop i5"?
Rs. 6,299.30 and Rs. 47,699.10 (from the Products sheet).
2. What is each region's 2025 achievement vs target?
Sales 2025 (SUMIFS) ÷ target (XLOOKUP from Targets):
| Region | Sales 2025 | Target | Achievement |
|---|---|---|---|
| North | 12,24,914.50 | 12,00,000 | 102.1% |
| South | 10,37,129.45 | 11,50,000 | 90.2% |
| East | 10,48,468.85 | 9,50,000 | 110.4% |
| West | 12,22,676.80 | 12,50,000 | 97.8% |
| Central | 8,58,346.45 | 9,00,000 | 95.4% |
East over-achieved; South is furthest behind.
3. How do you fill a blank region from the city?
Create a two-column list of city → region, then in the region column: =IF([@region]="", XLOOKUP([@city], CityRegion[city], CityRegion[region], "Check"), [@region]). Clean the city names (TRIM/PROPER, Bangalore→Bengaluru) first, or the lookup fails.
Summary#
- Lookups combine information from different tables.
- VLOOKUP: first-column search, column number, always use FALSE for exact match.
- XLOOKUP: separate lookup/return ranges, exact by default, if_not_found, left lookups, multiple columns.
- INDEX-MATCH works everywhere and supports two-way lookups.
- Approximate match on sorted tables handles slabs and bands.
-
N/A usually means dirty data - fix the cause, not just the symptom.#