Microsoft Excel Mastery

Part IV: Lookup & Reference Functions

VLOOKUP, HLOOKUP, XLOOKUP, INDEX-MATCH, Dynamic Arrays β€” with real Indian business examples from GST, CBSE, Flipkart, Zomato & TCS.

πŸ” 5 Chapters  |  πŸ“Š 100+ Solved Examples  |  πŸ“ 25+ MCQs  |  🎯 19 Interview Questions  |  πŸš€ 5 Mini Projects

Chapter 13

VLOOKUP β€” Vertical Lookup

🏒 How Flipkart Looks Up Product Prices in Milliseconds

Imagine Flipkart's catalogue with 150 million+ products. When a customer searches for "Samsung Galaxy S24", the system must instantly look up its price, stock status, seller details, and delivery time from a massive product database. This is essentially what VLOOKUP does β€” you give it a product ID, and it fetches the corresponding information from a table. In the corporate world, VLOOKUP is the single most-used Excel function after SUM.

FlipkartTCSInfosysReliance
Learning Objectives

What You'll Learn

  • Understand the syntax and all 4 arguments of VLOOKUP
  • Distinguish between Exact Match (FALSE/0) and Approximate Match (TRUE/1)
  • Use VLOOKUP to look up student marks, product prices, employee details, and GST rates
  • Troubleshoot common VLOOKUP errors: #N/A, #REF!, #VALUE!
  • Understand limitations of VLOOKUP and when to use alternatives
  • Use VLOOKUP with wildcards for partial matching
  • Perform two-way lookups using VLOOKUP + MATCH
  • Build a complete Student Result Lookup System
Theory & Concepts

What is VLOOKUP?

VLOOKUP stands for Vertical Lookup. It searches for a value in the first column of a table and returns a value from a specified column in the same row. Think of it like looking up a word in a dictionary β€” you search for the word (first column) and read its meaning (another column in the same row).

πŸ“ VLOOKUP Syntax
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
lookup_value β€” The value to search for in the first column of the table.
table_array β€” The range of cells containing the data table (lookup column must be first).
col_index_num β€” The column number in the table from which to return the value (1 = first column).
range_lookup β€” FALSE (or 0) for exact match; TRUE (or 1) for approximate match. Always use FALSE unless you specifically need approximate matching.

Exact Match vs Approximate Match

This is the most critical concept in VLOOKUP. The 4th argument determines how Excel searches:

FeatureExact Match (FALSE / 0)Approximate Match (TRUE / 1)
What it doesFinds only an exact match of the lookup valueFinds the closest value less than or equal to lookup value
Data sorting required?No β€” works with unsorted dataYes β€” first column MUST be sorted ascending
If no match foundReturns #N/A errorReturns the next smaller value's row
Common use caseProduct ID lookup, Student roll numberTax slab lookup, Grade assignment, Commission tiers
Recommended?Yes β€” use this by defaultOnly for range-based lookups
[Screenshot: VLOOKUP function dialog box showing all 4 arguments with descriptions]

Real-World Analogy

Think of VLOOKUP like a railway reservation chart. You have a PNR number (lookup_value). The chart (table_array) has PNR in the first column, followed by passenger name, berth, coach, and status. You look up your PNR and read across to find your berth (col_index_num = 4 for berth column). Exact match means you need the exact PNR β€” not "close enough".

Step-by-Step: Your First VLOOKUP

Let's create a Student Marks Database. Enter this data in cells A1:E6:

Roll No (A)Name (B)Maths (C)Science (D)English (E)
101Aarav Sharma859278
102Priya Patel918895
103Rohan Gupta766982
104Sneha Iyer949791
105Vikram Singh687371

Step 1: In cell G2, type the Roll Number you want to look up: 103

Step 2: In cell H2, enter the formula:

=VLOOKUP(G2, A2:E6, 2, FALSE)

Step 3: Press Enter. Result: Rohan Gupta

[Screenshot: Excel showing VLOOKUP formula in H2 returning "Rohan Gupta" for Roll No 103]

How it works:

  1. Excel searches for 103 in the first column (A2:A6) of the table
  2. It finds 103 in row 4 (A4)
  3. col_index_num = 2, so it returns the value from the 2nd column of that row β†’ B4 = "Rohan Gupta"
  4. FALSE means exact match β€” it won't accept 102 or 104 as "close enough"

Worked Examples β€” Exact Match

Example 1: Student Maths Marks Lookup

Formula
=VLOOKUP(104, A2:E6, 3, FALSE)
Result: 94 β€” Looks up Roll No 104 (Sneha Iyer) and returns the 3rd column (Maths marks).

Example 2: Product Price Lookup

Product ID (A)Product Name (B)Price β‚Ή (C)GST % (D)Stock (E)
P001Wireless Mouse59918150
P002USB Keyboard89918200
P003Monitor 24"129992845
P004Laptop Stand14991880
P005Webcam HD24991860
Formula β€” Look up price of P003
=VLOOKUP("P003", A2:E6, 3, FALSE)
Result: 12999 β€” Finds P003 in the first column and returns the price (3rd column).
Formula β€” Calculate price with GST
=VLOOKUP("P003",A2:E6,3,FALSE) * (1 + VLOOKUP("P003",A2:E6,4,FALSE)/100)
Result: 16638.72 β€” 12999 Γ— (1 + 28/100) = 12999 Γ— 1.28 = β‚Ή16,638.72 including 28% GST.

Example 3: Employee Details Lookup

Emp IDNameDepartmentSalary β‚ΉCity
E1001Amit KumarIT85000Bengaluru
E1002Neha ReddyHR72000Hyderabad
E1003Raj MalhotraFinance95000Mumbai
E1004Kavita NairIT88000Chennai
E1005Suresh JoshiMarketing68000Pune
=VLOOKUP("E1003", A2:E6, 4, FALSE)   β†’ Result: 95000
=VLOOKUP("E1004", A2:E6, 3, FALSE)   β†’ Result: IT
=VLOOKUP("E1005", A2:E6, 5, FALSE)   β†’ Result: Pune

Approximate Match β€” Tax Slab Lookup

Approximate match is perfect for range-based lookups where you need to find which bracket a value falls into. The classic Indian example is the Income Tax Slab.

Indian Income Tax Slabs (New Regime FY 2024-25):

Income From β‚Ή (A)Tax Rate % (B)
00
3000015
70000110
100000115
120000120
150000130

Note: The "Income From" column MUST be sorted in ascending order for approximate match.

Example 1 β€” Income β‚Ή8,50,000
=VLOOKUP(850000, A2:B7, 2, TRUE)
Result: 10 β€” Excel searches for 850000. It doesn't find an exact match, so it returns the rate for the largest value ≀ 850000, which is 700001 β†’ 10%.
Example 2 β€” Income β‚Ή4,50,000
=VLOOKUP(450000, A2:B7, 2, TRUE)
Result: 5 β€” Largest value ≀ 450000 is 300001 β†’ 5% rate.
Example 3 β€” Income β‚Ή18,00,000
=VLOOKUP(1800000, A2:B7, 2, TRUE)
Result: 30 β€” Largest value ≀ 1800000 is 1500001 β†’ 30% rate.
Unsorted data with approximate match: If the first column is NOT sorted in ascending order, VLOOKUP with TRUE will return incorrect results without any error message. This is the most dangerous VLOOKUP mistake because Excel gives a wrong answer silently. Always sort your data before using approximate match.

GST Rate Lookup

HSN Code (A)Product Category (B)GST Rate % (C)
0401Milk & Cream0
1006Rice5
3004Medicines12
6109T-shirts & Vests5
8471Computers & Laptops18
8703Motor Cars28
=VLOOKUP("8471", A2:C7, 3, FALSE)   β†’ Result: 18 (Computers attract 18% GST)
=VLOOKUP("0401", A2:C7, 2, FALSE)   β†’ Result: Milk & Cream
=VLOOKUP("8703", A2:C7, 3, FALSE)   β†’ Result: 28 (Cars attract 28% GST)

VLOOKUP with Wildcards

You can use * (any number of characters) and ? (single character) as wildcards in exact match VLOOKUP:

Wildcard Example β€” Find any employee with name starting with "Ka"
=VLOOKUP("Ka*", B2:E6, 1, FALSE)
Result: Kavita Nair β€” The * matches any characters after "Ka". Note: the lookup column here must contain the names.
=VLOOKUP("*Kumar", B2:E6, 1, FALSE)  β†’ Amit Kumar (ends with Kumar)
=VLOOKUP("???a Reddy", B2:E6, 1, FALSE)  β†’ Neha Reddy (? matches single character)

Two-Way Lookup: VLOOKUP + MATCH

Standard VLOOKUP requires you to hard-code the column number. But what if you want users to choose which subject's marks to look up? Use MATCH to make the column number dynamic:

Two-Way Lookup Formula
=VLOOKUP(G2, A1:E6, MATCH(H1, A1:E1, 0), FALSE)
If G2 = 103 (Roll No) and H1 = "Science", MATCH finds that "Science" is in position 4 of the header row. VLOOKUP then returns col 4 for Roll No 103 β†’ Result: 69

Pincode-to-City Lookup

PincodeCityStateZone
110001New DelhiDelhiNorth
400001MumbaiMaharashtraWest
560001BengaluruKarnatakaSouth
600001ChennaiTamil NaduSouth
700001KolkataWest BengalEast
500001HyderabadTelanganaSouth
=VLOOKUP(560001, A2:D7, 2, FALSE)  β†’ Bengaluru
=VLOOKUP(400001, A2:D7, 3, FALSE)  β†’ Maharashtra
=VLOOKUP(700001, A2:D7, 4, FALSE)  β†’ East

Common Errors & Troubleshooting

#N/A Error: The lookup value doesn't exist in the first column. Common causes: (1) Extra spaces β€” use =VLOOKUP(TRIM(G2), ...), (2) Number stored as text β€” use =VLOOKUP(VALUE(G2), ...), (3) Typo in the lookup value.
#REF! Error: The col_index_num is greater than the number of columns in table_array. E.g., if your table has 5 columns and you use col_index_num = 6, you get #REF!.
Wrong column index: Remember, col_index_num counts from the FIRST column of table_array, not from column A. If your table starts at column C, then col_index_num = 1 refers to column C, not column A.
VLOOKUP can only look RIGHT: The lookup column must be the leftmost column in your table_array. If you need to look left, use INDEX-MATCH or XLOOKUP instead.
Wrap VLOOKUP in IFERROR to handle #N/A gracefully:
=IFERROR(VLOOKUP(G2,A2:E6,2,FALSE), "Roll No Not Found")
This shows a friendly message instead of an ugly error.

F2 β€” Edit cell to see formula references highlighted in color

Ctrl + ` β€” Toggle formula view to see all formulas at once

F4 β€” Toggle absolute/relative references (critical for locking table_array: $A$2:$E$6)

Tab β€” Accept formula autocomplete suggestion

VLOOKUP Limitations

LimitationExplanationAlternative
Can only look rightLookup column must be leftmostINDEX-MATCH, XLOOKUP
Single column returnReturns value from one column onlyMultiple VLOOKUPs or XLOOKUP
Column index breaks on insertIf you insert a column, the hard-coded col_index changesVLOOKUP+MATCH or INDEX-MATCH
Returns first match onlyCan't find 2nd, 3rd occurrenceFILTER function, helper columns
Slower on large datasetsScans entire column for each lookupINDEX-MATCH is faster
Solved Examples

25 Solved VLOOKUP Examples

Examples 4-8: Employee Database Lookups

=VLOOKUP("E1001",A2:E6,2,FALSE)              β†’ Amit Kumar
=VLOOKUP("E1002",A2:E6,4,FALSE)              β†’ 72000
=VLOOKUP("E1004",A2:E6,5,FALSE)              β†’ Chennai
=IFERROR(VLOOKUP("E9999",A2:E6,2,FALSE),"Not Found")  β†’ Not Found
=VLOOKUP("E10"&"03",A2:E6,3,FALSE)           β†’ Finance (concatenation works)

Examples 9-13: Product Calculations

=VLOOKUP("P001",A2:E6,3,FALSE)+100                    β†’ 699 (price + shipping)
=VLOOKUP("P004",A2:E6,3,FALSE)*1.18                   β†’ 1768.82 (price with 18% GST)
=VLOOKUP("P005",A2:E6,5,FALSE)>50                     β†’ TRUE (stock > 50?)
=IF(VLOOKUP("P002",A2:E6,5,FALSE)>100,"In Stock","Low Stock") β†’ In Stock
=VLOOKUP("P003",A2:E6,3,FALSE)*VLOOKUP("P003",A2:E6,5,FALSE) β†’ 584955 (value of stock)

Examples 14-18: Grade Assignment with Approximate Match

Min Marks (A)Grade (B)
0F
33D
45C
60B
75A
90A+
=VLOOKUP(85, A2:B7, 2, TRUE)    β†’ A  (85 falls between 75 and 89)
=VLOOKUP(92, A2:B7, 2, TRUE)    β†’ A+ (92 β‰₯ 90)
=VLOOKUP(44, A2:B7, 2, TRUE)    β†’ D  (44 falls between 33 and 44)
=VLOOKUP(60, A2:B7, 2, TRUE)    β†’ B  (exact boundary = 60)
=VLOOKUP(25, A2:B7, 2, TRUE)    β†’ F  (25 falls between 0 and 32)

Examples 19-22: VLOOKUP with Other Functions

=UPPER(VLOOKUP(101,A2:E6,2,FALSE))            β†’ AARAV SHARMA
=LEFT(VLOOKUP(102,A2:E6,2,FALSE),5)            β†’ Priya
=VLOOKUP(103,A2:E6,3,FALSE)+VLOOKUP(103,A2:E6,4,FALSE)+VLOOKUP(103,A2:E6,5,FALSE) β†’ 227 (total marks)
=AVERAGE(VLOOKUP(104,A2:E6,3,FALSE),VLOOKUP(104,A2:E6,4,FALSE),VLOOKUP(104,A2:E6,5,FALSE)) β†’ 94

Examples 23-25: Advanced VLOOKUP

/* Two-way lookup with MATCH */
=VLOOKUP(102, A1:E6, MATCH("English",A1:E1,0), FALSE)  β†’ 95

/* VLOOKUP returning column header */
=INDEX(A1:E1, MATCH(MAX(C2:E2), C2:E2, 0)+2)           β†’ Returns subject with highest marks

/* Nested IF with VLOOKUP */
=IF(VLOOKUP(105,A2:E6,3,FALSE)>=75, "Distinction",
 IF(VLOOKUP(105,A2:E6,3,FALSE)>=60, "First Class",
 IF(VLOOKUP(105,A2:E6,3,FALSE)>=45, "Second Class", "Fail")))  β†’ Second Class

Practice Exercises

Use this Zomato Restaurant Dataset for exercises:

Rest IDRestaurant NameCuisineRatingAvg Cost β‚ΉCity
Z001Barbeque NationNorth Indian4.21200Bengaluru
Z002Domino's PizzaItalian3.8400Mumbai
Z003Saravana BhavanSouth Indian4.5350Chennai
Z004Haldiram'sSnacks4.0250Delhi
Z005Paradise BiryaniHyderabadi4.6500Hyderabad
Z006MTR RestaurantSouth Indian4.3450Bengaluru

Exercise 1: Look up the cuisine type of restaurant Z004. Answer: =VLOOKUP("Z004",A2:F7,3,FALSE) β†’ Snacks

Exercise 2: Find the average cost for Z005. Answer: =VLOOKUP("Z005",A2:F7,5,FALSE) β†’ 500

Exercise 3: Look up the rating of Saravana Bhavan and check if it's above 4. Answer: =VLOOKUP("Z003",A2:F7,4,FALSE)>4 β†’ TRUE

Exercise 4: Find which city Z006 is in and display "Delivery Available" if it's Bengaluru. Answer: =IF(VLOOKUP("Z006",A2:F7,6,FALSE)="Bengaluru","Delivery Available","Check Coverage")

Exercise 5: Calculate the GST amount (5%) on the average cost for Z001. Answer: =VLOOKUP("Z001",A2:F7,5,FALSE)*0.05 β†’ 60

Exercise 6: Use IFERROR to show "Restaurant Not Listed" when looking up Z999. Answer: =IFERROR(VLOOKUP("Z999",A2:F7,2,FALSE),"Restaurant Not Listed")

Exercise 7: Use a wildcard VLOOKUP to find any restaurant starting with "Para". Answer: =VLOOKUP("Para*",B2:F7,1,FALSE) β†’ Paradise Biryani

Exercise 8: Create a two-way lookup: Given Rest ID in H1 and column header "Rating" in I1, write the formula. Answer: =VLOOKUP(H1,A1:F7,MATCH(I1,A1:F1,0),FALSE)

Exercise 9: Look up the cost for Z002 and Z003, and find their total. Answer: =VLOOKUP("Z002",A2:F7,5,FALSE)+VLOOKUP("Z003",A2:F7,5,FALSE) β†’ 750

Exercise 10: Write a formula that returns "Premium" if avg cost > 500, else "Budget" for any given restaurant ID in cell H1. Answer: =IF(VLOOKUP(H1,A2:F7,5,FALSE)>500,"Premium","Budget")

Assignment

πŸ“‹ Assignment: Indian Railway Fare Calculator

Create a workbook with these components:

  1. A Train Master Data sheet with columns: Train No, Train Name, From Station, To Station, Sleeper Fare β‚Ή, AC-3 Fare β‚Ή, AC-2 Fare β‚Ή, AC-1 Fare β‚Ή, Distance (km)
  2. Enter at least 10 trains (Rajdhani, Shatabdi, Duronto, etc.)
  3. A Fare Lookup sheet where user enters Train No and Class, and the fare is automatically looked up using VLOOKUP + MATCH
  4. Add IFERROR to handle invalid train numbers
  5. Calculate the GST (5% on AC fares, 0% on Sleeper) using an IF formula combined with VLOOKUP
MCQ Assessment

VLOOKUP Quiz (5 MCQs)

Q1

What does the 4th argument FALSE mean in VLOOKUP?

  1. Search from bottom to top
  2. Return approximate match
  3. Return exact match only
  4. Ignore errors
βœ… Answer: (c) β€” FALSE (or 0) tells VLOOKUP to find an exact match. TRUE would allow approximate matching.
Q2

Which error will =VLOOKUP("XYZ", A2:C10, 5, FALSE) produce if the table has only 3 columns?

  1. #N/A
  2. #VALUE!
  3. #REF!
  4. #NAME?
βœ… Answer: (c) β€” #REF! occurs when col_index_num exceeds the number of columns in table_array. You asked for column 5 from a 3-column table.
Q3

For approximate match (TRUE) to work correctly, the first column of the table must be:

  1. Sorted in descending order
  2. Sorted in ascending order
  3. Contain unique values only
  4. Contain text values only
βœ… Answer: (b) β€” Approximate match requires the first column to be sorted in ascending order. Otherwise, results are unpredictable.
Q4

VLOOKUP can search for a value in which direction?

  1. Left to right in a row
  2. Top to bottom in the first column, then returns a value to the right
  3. Right to left in a row
  4. Bottom to top in a column
βœ… Answer: (b) β€” VLOOKUP searches vertically (top to bottom) in the first column and can only return values from columns to the right.
Q5

What will =VLOOKUP(102, A2:E6, 2, FALSE) return if Roll No 102 appears twice in the data?

  1. Both values
  2. The value from the first occurrence
  3. The value from the last occurrence
  4. #VALUE! error
βœ… Answer: (b) β€” VLOOKUP always returns the first match found (top to bottom). It cannot return multiple matches.
Mini Project

πŸš€ Student Result Lookup System

πŸ“Š Project: Complete Student Result Lookup System

Problem Statement

Build an interactive Excel-based Student Result Lookup System for a CBSE school. A teacher enters a Roll Number, and the system automatically displays the student's complete result card.

Requirements

  1. Database Sheet: Contains 20 students with columns: Roll No, Name, Class, Section, Maths, Science, English, Hindi, Social Science, Computer, Total, Percentage, Grade
  2. Lookup Sheet: Has an input cell for Roll Number and displays:
    • Student Name (VLOOKUP col 2)
    • Class & Section (VLOOKUP cols 3, 4)
    • Individual subject marks (VLOOKUP cols 5-10)
    • Total, Percentage, Grade (VLOOKUP cols 11-13)
    • Pass/Fail status using IF with VLOOKUP
    • Rank using RANK function
  3. All lookups must use IFERROR for invalid roll numbers
  4. Use conditional formatting to highlight marks below 33 (fail) in red
  5. Add a Data Validation dropdown for Roll Number selection

Deliverables

  • Excel file with Database and Lookup sheets
  • Formatted result card layout with school header
  • At least 20 student records with realistic CBSE data
  • Auto-calculated Total, Percentage, and Grade
[Screenshot: Final Student Result Lookup System showing Roll No input and all auto-populated fields]
Interview Corner

VLOOKUP Interview Questions

Q1: What is the difference between VLOOKUP with TRUE and FALSE?

Answer: FALSE (exact match) searches for the exact lookup value and returns #N/A if not found. TRUE (approximate match) finds the largest value that is less than or equal to the lookup value β€” but requires the first column to be sorted in ascending order. Use FALSE for ID lookups (Employee ID, Product Code) and TRUE for range-based lookups (tax slabs, grade assignment, commission tiers).

Q2: A VLOOKUP is returning #N/A even though the value exists in the table. What could be wrong?

Answer: Common causes: (1) Extra spaces β€” use TRIM() on both lookup and table values. (2) Number stored as text or vice versa β€” one cell has 101 as a number, the other as text "101". Use VALUE() or TEXT() to convert. (3) Hidden characters β€” use CLEAN() + TRIM(). (4) Lookup value not in first column of the specified table_array. (5) Table_array doesn't cover the correct range.

Q3: Why is INDEX-MATCH considered better than VLOOKUP?

Answer: (1) INDEX-MATCH can look in any direction β€” left, right, up, down β€” while VLOOKUP only looks right. (2) INDEX-MATCH is not affected by column insertions/deletions since it references actual ranges, not column numbers. (3) INDEX-MATCH is faster on large datasets because MATCH only searches the lookup column, while VLOOKUP loads the entire table_array. (4) INDEX-MATCH supports multiple criteria more naturally.

Q4: How would you use VLOOKUP to look up data from a different sheet or workbook?

Answer: For a different sheet: =VLOOKUP(A2, Sheet2!A:E, 3, FALSE). For a different workbook (must be open): =VLOOKUP(A2, [Workbook.xlsx]Sheet1!A:E, 3, FALSE). Best practice: use named ranges to make formulas more readable, e.g., =VLOOKUP(A2, EmployeeData, 3, FALSE) where EmployeeData is a named range.

Q5: How do you handle VLOOKUP returning the first match when you need all matches?

Answer: VLOOKUP always returns the first match. For all matches: (1) Use FILTER() function (Excel 365/2021): =FILTER(B2:B100, A2:A100="IT"). (2) Use helper column with COUNTIF to create unique keys. (3) Use Power Query for complex multi-match scenarios. (4) In older Excel, use a combination of SMALL, IF, ROW, and INDEX as an array formula.

Pedagogy tip: Start VLOOKUP teaching with a physical analogy β€” bring a printed phone directory to class and ask students to look up a name. They naturally search the first column (name) and read across (phone number). This IS VLOOKUP. Then transition to Excel. Students struggle most with: (1) understanding that lookup column must be leftmost, (2) the difference between TRUE/FALSE, and (3) locking table_array with $. Spend extra time on these three concepts.

πŸ“‹ Chapter 13 Summary

  • VLOOKUP searches the first column of a table and returns a value from a specified column
  • Use FALSE (exact match) for ID-based lookups; TRUE (approximate) for range-based lookups
  • Approximate match requires sorted ascending data in the first column
  • Always wrap with IFERROR() for production-ready formulas
  • Use F4 to lock table_array with $ signs when copying formulas
  • VLOOKUP can only look right β€” for leftward lookups, use INDEX-MATCH or XLOOKUP
  • Use wildcards * and ? for partial matching in exact match mode
  • Combine with MATCH() for dynamic column selection (two-way lookup)
Chapter 14

HLOOKUP β€” Horizontal Lookup

πŸ“Š When Your Data Flows Sideways

Not all data sits in neat vertical columns. Think of a CBSE report card where subjects are written across the top (Jan, Feb, Mar, Apr...) and each student has one row. Or a quarterly sales dashboard where Q1, Q2, Q3, Q4 are column headers. When your data is arranged horizontally, VLOOKUP can't help β€” you need its sibling, HLOOKUP.

CBSESchoolsFinancial Reports
Learning Objectives

What You'll Learn

  • Understand HLOOKUP syntax and all its arguments
  • Know when to choose HLOOKUP over VLOOKUP
  • Apply HLOOKUP to horizontal datasets (semester marks, monthly sales)
  • Handle errors and understand limitations
  • Build a Semester Performance Tracker mini project
Theory & Concepts

What is HLOOKUP?

HLOOKUP stands for Horizontal Lookup. It searches for a value in the first row of a table and returns a value from a specified row in the same column. It's the horizontal counterpart of VLOOKUP.

πŸ“ HLOOKUP Syntax
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
lookup_value β€” The value to search for in the first row of the table.
table_array β€” The range containing the data (lookup row must be the first row).
row_index_num β€” The row number in the table from which to return the value (1 = first row).
range_lookup β€” FALSE for exact match; TRUE for approximate match.

VLOOKUP vs HLOOKUP β€” When to Use Which?

FeatureVLOOKUPHLOOKUP
Data orientationVertical (data in columns)Horizontal (data in rows)
Searches inFirst columnFirst row
Returns fromSpecified column numberSpecified row number
Index argumentcol_index_numrow_index_num
Common use caseMost database tablesTime series, schedule tables
Frequency of useVery common (90%+ use cases)Rare (niche use cases)
In real-world Excel usage, VLOOKUP is used about 10x more than HLOOKUP because most databases store records as rows (vertical). HLOOKUP is mostly seen in academic schedules, financial summary tables, and legacy reports where data was arranged horizontally.

Step-by-Step: Your First HLOOKUP

A CBSE school stores monthly test scores horizontally. Data in A1:G4:

Jan (B)Feb (C)Mar (D)Apr (E)May (F)Jun (G)
Maths (A2)788285799188
Science (A3)727580838790
English (A4)858882909295

Question: What was the Maths score in March?

Formula
=HLOOKUP("Mar", B1:G4, 2, FALSE)
Result: 85 β€” Searches for "Mar" in the first row (B1:G1), finds it in column D. Returns row 2 value from that column β†’ D2 = 85.
Example 2 β€” Science score in May
=HLOOKUP("May", B1:G4, 3, FALSE)
Result: 87 β€” Finds "May" in row 1, returns row 3 (Science) β†’ 87.
Example 3 β€” English score in Jun
=HLOOKUP("Jun", B1:G4, 4, FALSE)
Result: 95 β€” Finds "Jun" in row 1, returns row 4 (English) β†’ 95.

Worked Examples β€” Quarterly Sales

TCS Quarterly Revenue (β‚Ή Crores):

Q1Q2Q3Q4
Revenue59692612376058362613
Profit11342117261105812434
Employees601400603456600987607000
=HLOOKUP("Q2", B1:E4, 2, FALSE)       β†’ 61237  (Q2 Revenue)
=HLOOKUP("Q4", B1:E4, 3, FALSE)       β†’ 12434  (Q4 Profit)
=HLOOKUP("Q1", B1:E4, 4, FALSE)       β†’ 601400 (Q1 Employees)
=HLOOKUP("Q4",B1:E4,2,FALSE) - HLOOKUP("Q1",B1:E4,2,FALSE)  β†’ 2921 (Revenue growth Q1β†’Q4)
=HLOOKUP("Q3",B1:E4,3,FALSE)/HLOOKUP("Q3",B1:E4,2,FALSE)*100 β†’ 18.25% (Q3 Profit Margin)

Semester-wise Student Performance

Sem 1Sem 2Sem 3Sem 4Sem 5Sem 6
Aarav7.88.28.57.99.18.8
Priya8.58.89.08.79.29.4
Rohan6.57.07.37.88.08.5
=HLOOKUP("Sem 4", B1:G4, 2, FALSE)     β†’ 7.9  (Aarav's Sem 4 SGPA)
=HLOOKUP("Sem 6", B1:G4, 3, FALSE)     β†’ 9.4  (Priya's Sem 6 SGPA)
=HLOOKUP("Sem 1", B1:G4, 4, FALSE)     β†’ 6.5  (Rohan's Sem 1 SGPA)

/* Average SGPA across semesters for Priya */
=AVERAGE(HLOOKUP("Sem 1",B1:G4,3,FALSE), HLOOKUP("Sem 2",B1:G4,3,FALSE),
         HLOOKUP("Sem 3",B1:G4,3,FALSE), HLOOKUP("Sem 4",B1:G4,3,FALSE),
         HLOOKUP("Sem 5",B1:G4,3,FALSE), HLOOKUP("Sem 6",B1:G4,3,FALSE))  β†’ 8.93

/* Improvement from Sem 1 to Sem 6 for Rohan */
=HLOOKUP("Sem 6",B1:G4,4,FALSE) - HLOOKUP("Sem 1",B1:G4,4,FALSE)  β†’ 2.0

HLOOKUP with Approximate Match

Delivery time based on distance (km):

Distance05020050010002000
Days1235710
=HLOOKUP(150, A1:F2, 2, TRUE)    β†’ 2 (150 falls between 50 and 199)
=HLOOKUP(750, A1:F2, 2, TRUE)    β†’ 5 (750 falls between 500 and 999)
=HLOOKUP(2500, A1:F2, 2, TRUE)   β†’ 10 (2500 β‰₯ 2000)

More Solved Examples

Indian Festival Sales Data

DiwaliHoliEidChristmasNavratri
Flipkart β‚ΉCr4500085006200120009800
Amazon β‚ΉCr4200078005900135008700
Meesho β‚ΉCr85003200210045003800
=HLOOKUP("Diwali", B1:F4, 2, FALSE)    β†’ 45000 (Flipkart Diwali sales)
=HLOOKUP("Eid", B1:F4, 3, FALSE)       β†’ 5900 (Amazon Eid sales)
=HLOOKUP("Diwali",B1:F4,2,FALSE) + HLOOKUP("Diwali",B1:F4,3,FALSE)  β†’ 87000 (Total Diwali: Flipkart + Amazon)
=HLOOKUP("Christmas",B1:F4,3,FALSE) > HLOOKUP("Christmas",B1:F4,2,FALSE)  β†’ TRUE (Amazon beat Flipkart at Christmas)
Using HLOOKUP when VLOOKUP would work: If your data can easily be transposed to a vertical format, use VLOOKUP instead. HLOOKUP should only be used when the data is naturally horizontal (time series, schedules). Most Excel experts recommend converting horizontal data to vertical using Paste Special β†’ Transpose.
Teaching tip: HLOOKUP gets maybe 10% of class time. Teach it as "VLOOKUP rotated 90Β°" β€” same logic, different direction. Focus more time on XLOOKUP which replaces both VLOOKUP and HLOOKUP.

Practice Exercises

Exercise 1: Using the monthly test scores table, find the Science score in February. Answer: =HLOOKUP("Feb",B1:G4,3,FALSE) β†’ 75

Exercise 2: Find the average of Maths scores across all 6 months using HLOOKUP. Answer: Use 6 HLOOKUP calls inside AVERAGE

Exercise 3: Look up TCS Q3 Revenue and calculate 22% tax on it. Answer: =HLOOKUP("Q3",B1:E4,2,FALSE)*0.22 β†’ 13328.26

Exercise 4: Find the profit margin (Profit/Revenue) for TCS in Q1. Answer: =HLOOKUP("Q1",B1:E4,3,FALSE)/HLOOKUP("Q1",B1:E4,2,FALSE) β†’ 19.0%

Exercise 5: Use IFERROR with HLOOKUP to return "Quarter Not Found" for an invalid quarter. Answer: =IFERROR(HLOOKUP("Q5",B1:E4,2,FALSE),"Quarter Not Found")

Exercise 6: Find the festival where Amazon had the highest sales using HLOOKUP+MAX. Hint: Combine INDEX, MATCH, and MAX

Exercise 7: Look up delivery days for a 350 km distance using approximate match. Answer: =HLOOKUP(350,A1:F2,2,TRUE) β†’ 3

Exercise 8: Create a two-way lookup combining HLOOKUP with an IF to check semester performance. Answer: =IF(HLOOKUP("Sem 6",B1:G4,3,FALSE)>9,"Excellent","Good")

Ctrl + Shift + T β€” Transpose selected range (via Paste Special)

Alt + = β€” Auto-SUM (works great with HLOOKUP results)

Ctrl + ~ β€” Toggle between value view and formula view

More Examples & Assignments

HLOOKUP Limitations & Alternatives

LimitationDescriptionAlternative
Can only look downLookup value must be in the first rowINDEX-MATCH or XLOOKUP
Row index is fragileInserting rows changes the indexINDEX-MATCH
Not common in databasesMost data is stored verticallyTranspose + VLOOKUP
Deprecated in modern ExcelXLOOKUP handles both H and VXLOOKUP
MCQ Assessment

HLOOKUP Quiz (5 MCQs)

Q1

HLOOKUP searches for a value in the:

  1. First column of a table
  2. First row of a table
  3. Last row of a table
  4. Any row of a table
βœ… Answer: (b) β€” HLOOKUP stands for Horizontal Lookup and searches in the first ROW.
Q2

The "H" in HLOOKUP stands for:

  1. High
  2. Header
  3. Horizontal
  4. Hybrid
βœ… Answer: (c) β€” H stands for Horizontal, as it searches horizontally across the first row.
Q3

In =HLOOKUP("Q2", A1:E4, 3, FALSE), what does "3" represent?

  1. Third column
  2. Third row from the top of the table
  3. Third value found
  4. Third character of the lookup value
βœ… Answer: (b) β€” The 3rd argument in HLOOKUP is row_index_num, which specifies the row number from which to return the value.
Q4

Which function can replace both VLOOKUP and HLOOKUP in modern Excel?

  1. INDEX
  2. MATCH
  3. XLOOKUP
  4. LOOKUP
βœ… Answer: (c) β€” XLOOKUP (Excel 365/2021) can search both vertically and horizontally, replacing both VLOOKUP and HLOOKUP.
Q5

When would you choose HLOOKUP over VLOOKUP?

  1. When data is in a standard database table
  2. When lookup values are arranged in a row across the top
  3. When you need to look left
  4. When you have more than 1 million rows
βœ… Answer: (b) β€” Use HLOOKUP when your data is arranged horizontally (categories as column headers, values in rows below).
Mini Project

πŸš€ Semester Performance Tracker

πŸ“Š Project: B.Tech Semester Performance Tracker

Problem Statement

Build a tracker for 10 B.Tech students of VIT/SRM/Manipal where semester-wise SGPA is stored horizontally (Sem 1 through Sem 8 as column headers). A user selects a student name and semester to view the SGPA.

Requirements

  1. Data Layout: Row 1 has semester headers (Sem 1 to Sem 8). Column A has student names. SGPA values (1.0 to 10.0) fill the grid.
  2. Lookup Panel: User enters Semester in one cell β†’ HLOOKUP retrieves the row. User enters Student Name β†’ used to pick the correct row_index_num via a helper MATCH formula.
  3. Display: SGPA for selected student + semester, plus their CGPA (average of all semesters), trend (improving/declining), and highest semester.
  4. Use conditional formatting: SGPA β‰₯ 9 = Green, 7-8.99 = Yellow, Below 7 = Red.

Deliverables

  • Excel file with Data and Dashboard sheets
  • Dynamic semester selection using Data Validation dropdown
  • Automatic CGPA calculation and performance classification

Interview Q1: When would you use HLOOKUP in a real project?

Answer: HLOOKUP is useful when data is naturally horizontal β€” budget templates with months as columns, comparison tables with products across the top, or legacy financial reports. However, in modern Excel (365/2021), XLOOKUP replaces HLOOKUP entirely. I'd typically transpose horizontal data to vertical and use VLOOKUP or INDEX-MATCH for better maintainability.

Interview Q2: Can HLOOKUP and VLOOKUP be combined?

Answer: Yes! For a true two-dimensional lookup. Example: =INDEX(B2:E4, MATCH(G1,A2:A4,0), MATCH(H1,B1:E1,0)). But you can also nest: =VLOOKUP(G1, A1:E4, MATCH(H1,A1:E1,0), FALSE) where MATCH dynamically determines the column. This is a common pattern for cross-referencing row and column headers.

Interview Q3: Is HLOOKUP being deprecated?

Answer: Not officially deprecated, but Microsoft recommends XLOOKUP for new work. HLOOKUP will remain for backward compatibility, but XLOOKUP is more versatile β€” it handles horizontal lookups naturally without a separate function. Companies migrating to Excel 365 should train employees on XLOOKUP as the standard lookup function.

πŸ“‹ Chapter 14 Summary

  • HLOOKUP searches the first row and returns a value from a specified row below
  • Use when data is arranged horizontally (months, quarters, semesters as columns)
  • Same TRUE/FALSE logic as VLOOKUP for exact vs approximate match
  • HLOOKUP is rarely used β€” most data is vertical; prefer XLOOKUP in modern Excel
  • Can be combined with MATCH for dynamic row selection
Chapter 15

XLOOKUP β€” The Modern Lookup

πŸš€ The Function That Replaced VLOOKUP

In August 2019, Microsoft introduced XLOOKUP β€” the function that makes VLOOKUP, HLOOKUP, and even many INDEX-MATCH combinations obsolete. It can look left, look right, return multiple columns, handle missing values gracefully, and search in reverse. Think of it as VLOOKUP 2.0. At companies like Infosys and Wipro, analysts who know XLOOKUP are already more productive than those still using VLOOKUP.

Excel 365Excel 2021InfosysWipro
Learning Objectives

What You'll Learn

  • Master the XLOOKUP syntax with all 6 arguments
  • Use XLOOKUP to look in any direction (left, right, horizontal, vertical)
  • Set custom "not found" messages without IFERROR
  • Understand all 4 match modes and 4 search modes
  • Return multiple columns with a single XLOOKUP
  • Perform nested XLOOKUP for two-dimensional lookups
  • Compare XLOOKUP vs VLOOKUP comprehensively
Theory & Concepts

XLOOKUP Syntax

πŸ“ XLOOKUP Syntax
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
lookup_value β€” The value to search for.
lookup_array β€” The range to search IN (single row or column).
return_array β€” The range to return FROM (can be multiple columns/rows!).
if_not_found β€” Optional. Custom text/value to return if no match found (replaces IFERROR).
match_mode β€” Optional. 0 = exact (default), -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcard.
search_mode β€” Optional. 1 = first to last (default), -1 = last to first, 2 = binary ascending, -2 = binary descending.

Match Modes Explained

Match ModeValueDescriptionUse Case
Exact Match0Finds only exact match (default)ID lookups, code lookups
Exact or Next Smaller-1If no exact match, returns next smallerTax slabs, grade boundaries
Exact or Next Larger1If no exact match, returns next largerShipping weight brackets
Wildcard2Allows * and ? wildcardsPartial name matching

Search Modes Explained

Search ModeValueDescriptionUse Case
First to Last1Search from top/left (default)Standard lookups
Last to First-1Search from bottom/rightFind most recent entry
Binary Ascending2Binary search on sorted ascending dataFast lookup on sorted data
Binary Descending-2Binary search on sorted descending dataReverse-sorted tables

XLOOKUP vs VLOOKUP β€” Comprehensive Comparison

FeatureVLOOKUPXLOOKUP
Look directionRight onlyAny direction
Not-found handlingReturns #N/A (needs IFERROR)Built-in if_not_found argument
Column indexHard-coded numberSeparate return_array (no index needed)
Column insert impactBreaks formulaUnaffected
Return multiple columnsNo (one at a time)Yes β€” returns entire row/range
Default matchApproximate (dangerous!)Exact (safe default)
Reverse searchNoYes (search_mode = -1)
Horizontal lookupNo (need HLOOKUP)Yes β€” same function
AvailabilityAll Excel versionsExcel 365, Excel 2021+
[Screenshot: Side-by-side comparison of VLOOKUP and XLOOKUP formulas for the same task, showing XLOOKUP's cleaner syntax]

Basic XLOOKUP Examples

Employee Database (same as Chapter 13):

Emp ID (A)Name (B)Department (C)Salary β‚Ή (D)City (E)
E1001Amit KumarIT85000Bengaluru
E1002Neha ReddyHR72000Hyderabad
E1003Raj MalhotraFinance95000Mumbai
E1004Kavita NairIT88000Chennai
E1005Suresh JoshiMarketing68000Pune

Example 1: Basic exact match

Look up employee name by ID
=XLOOKUP("E1003", A2:A6, B2:B6)
Result: Raj Malhotra β€” Searches for "E1003" in A2:A6, returns corresponding value from B2:B6. No column index number needed!

Example 2: Built-in error handling

Custom not-found message
=XLOOKUP("E9999", A2:A6, B2:B6, "Employee Not Found")
Result: Employee Not Found β€” No IFERROR wrapper needed! The 4th argument handles missing values directly.

Example 3: Looking LEFT (impossible with VLOOKUP!)

Find Emp ID by Name (leftward lookup)
=XLOOKUP("Kavita Nair", B2:B6, A2:A6)
Result: E1004 β€” Searches in column B (Name) and returns from column A (ID). VLOOKUP can't do this because it can only look right!

Example 4: Return multiple columns

Return Name, Department, and City in one formula
=XLOOKUP("E1002", A2:A6, B2:E6)
Result: Neha Reddy | HR | 72000 | Hyderabad β€” Returns the entire row! The result spills across 4 cells (B, C, D, E columns). This replaces 4 separate VLOOKUP formulas.

Example 5: Reverse search (find last occurrence)

Transaction log with duplicate customer IDs:

Cust IDDateAmount β‚Ή
C00101-Jan-20255000
C00215-Jan-20253200
C00120-Feb-20257500
C00310-Mar-20254100
C00105-Apr-20259200
Find the MOST RECENT transaction for C001
=XLOOKUP("C001", A2:A6, C2:C6, , 0, -1)
Result: 9200 β€” The search_mode = -1 searches from last to first, so it finds the latest entry for C001 (April). VLOOKUP would always return the first (5000).

XLOOKUP for Tax Slab Lookup

Income Tax with match_mode = -1 (exact or next smaller)
=XLOOKUP(850000, A2:A7, B2:B7, , -1)
Result: 10 β€” Using the tax slab table from Chapter 13. Match mode -1 finds the largest value ≀ 850000, which is 700001 β†’ 10%. No need to worry about TRUE/FALSE or sorted data warnings.

XLOOKUP for Horizontal Lookups

XLOOKUP replacing HLOOKUP β€” Maths score in March
=XLOOKUP("Mar", B1:G1, B2:G2)
Result: 85 β€” Searches "Mar" in the header row B1:G1, returns from the Maths row B2:G2. Same function handles both V and H lookups!

Nested XLOOKUP β€” Two-Dimensional Lookup

Look up a specific student's specific subject marks
=XLOOKUP(H1, A2:A6, XLOOKUP(I1, B1:E1, B2:E6))
If H1 = "Rohan Gupta" and I1 = "Science": The inner XLOOKUP finds the "Science" column from the headers, returning the entire column. The outer XLOOKUP then finds "Rohan Gupta" in that column. Result: 69

Wildcard Search with XLOOKUP

=XLOOKUP("*Kumar", B2:B6, D2:D6, "Not Found", 2)     β†’ 85000 (wildcard match_mode = 2)
=XLOOKUP("Ne??", B2:B6, C2:C6, "Not Found", 2)        β†’ HR (? matches single char)
=XLOOKUP("*al*", B2:B6, A2:A6, "Not Found", 2)        β†’ E1003 (Raj Malhotra contains "al")

More Solved Examples

GST Rate Lookup with XLOOKUP

=XLOOKUP("8471", A2:A7, C2:C7, "HSN Not Found")         β†’ 18
=XLOOKUP("0401", A2:A7, B2:B7, "HSN Not Found")         β†’ Milk & Cream
=XLOOKUP("9999", A2:A7, C2:C7, "Invalid HSN Code")      β†’ Invalid HSN Code

Reliance Industries β€” Segment Revenue Lookup

SegmentRevenue β‚ΉCrGrowth %Employees
Jio Platforms11244612.545000
Retail26575018.3350000
O2C (Oil)5378405.235000
Media8762-3.112000
Financial Services1895028.68500
=XLOOKUP("Retail", A2:A6, B2:B6)                        β†’ 265750
=XLOOKUP("Jio Platforms", A2:A6, C2:C6)                  β†’ 12.5
=XLOOKUP("Media", A2:A6, B2:D6)                          β†’ 8762 | -3.1 | 12000 (multi-column return)
=XLOOKUP(MAX(C2:C6), C2:C6, A2:A6)                      β†’ Financial Services (highest growth segment)
=XLOOKUP(MIN(C2:C6), C2:C6, A2:A6)                      β†’ Media (segment with negative growth)
XLOOKUP returns multiple columns: When return_array spans multiple columns, the result spills across adjacent cells. This is incredibly powerful β€” one formula replaces many. Just make sure the spill area is empty, or you'll get a #SPILL! error.
#SPILL! Error: When XLOOKUP tries to return multiple values but the adjacent cells are not empty, you get #SPILL!. Solution: Clear the cells where the results need to spill into, or use @ operator to force single-cell return: =@XLOOKUP(...)

Practice Exercises

Exercise 1: Use XLOOKUP to find the city of employee E1005. Answer: =XLOOKUP("E1005",A2:A6,E2:E6) β†’ Pune

Exercise 2: Find the employee ID of someone named "Neha Reddy" (leftward lookup). Answer: =XLOOKUP("Neha Reddy",B2:B6,A2:A6)

Exercise 3: Look up salary for E1001 with a custom "ID Invalid" message. Answer: =XLOOKUP("E1001",A2:A6,D2:D6,"ID Invalid")

Exercise 4: Return all details (Name, Dept, Salary, City) for E1004 in one formula. Answer: =XLOOKUP("E1004",A2:A6,B2:E6)

Exercise 5: Use wildcard to find any employee with "Joshi" in their name. Answer: =XLOOKUP("*Joshi*",B2:B6,A2:A6,"Not Found",2)

Exercise 6: Find the income tax rate for β‚Ή12,50,000 using match_mode -1. Answer: =XLOOKUP(1250000,A2:A7,B2:B7,,-1) β†’ 20

Exercise 7: Look up the last transaction amount for C001 using reverse search. Answer: =XLOOKUP("C001",A2:A6,C2:C6,,0,-1) β†’ 9200

Exercise 8: Find the Reliance segment with the most employees. Answer: =XLOOKUP(MAX(D2:D6),D2:D6,A2:A6) β†’ Retail

Exercise 9: Perform a nested XLOOKUP to find Rohan Gupta's English marks from the student database. Answer: =XLOOKUP("Rohan Gupta",B2:B6,XLOOKUP("English",A1:E1,A2:E6))

Exercise 10: Use XLOOKUP to find delivery days for 750 km distance (next larger match). Answer: =XLOOKUP(750,A1:F1,A2:F2,,1)

Ctrl + Shift + Enter β€” Enter array formula (not needed for XLOOKUP in Excel 365, but needed in some contexts)

Ctrl + / β€” Select the current array range (useful for spill ranges)

F9 β€” Evaluate part of a formula in the formula bar (select a portion and press F9)

MCQ Assessment

XLOOKUP Quiz (5 MCQs)

Q1

What is the default match_mode of XLOOKUP?

  1. Approximate match
  2. Exact match
  3. Wildcard match
  4. Binary search
βœ… Answer: (b) β€” XLOOKUP defaults to exact match (0), unlike VLOOKUP which defaults to approximate match (TRUE). This is a much safer default.
Q2

Which XLOOKUP feature eliminates the need for IFERROR?

  1. match_mode argument
  2. search_mode argument
  3. if_not_found argument
  4. return_array argument
βœ… Answer: (c) β€” The if_not_found (4th argument) lets you specify a custom value when no match is found, eliminating the need to wrap in IFERROR.
Q3

To find the LAST occurrence of a value, which search_mode should you use?

  1. 1
  2. -1
  3. 2
  4. 0
βœ… Answer: (b) β€” search_mode = -1 searches from last to first, finding the last occurrence of the lookup value.
Q4

What advantage does XLOOKUP have over VLOOKUP for column references?

  1. It uses a separate return_array instead of a column index number
  2. It automatically finds the column
  3. It uses column letters instead of numbers
  4. It doesn't need a table reference
βœ… Answer: (a) β€” XLOOKUP uses a return_array (e.g., C2:C6) instead of a column index (e.g., 3). This means inserting/deleting columns won't break the formula.
Q5

XLOOKUP is available in which Excel versions?

  1. All versions from Excel 2010
  2. Excel 2016 and later
  3. Excel 365 and Excel 2021 only
  4. Only Excel 365 (not Excel 2021)
βœ… Answer: (c) β€” XLOOKUP was introduced in Excel 365 (2019) and is also available in Excel 2021. It is NOT available in Excel 2019, 2016, or earlier.
Mini Project

πŸš€ Product Catalog Search Engine

πŸ“Š Project: Flipkart Product Catalog Search Engine with XLOOKUP

Problem Statement

Build a product search system for an e-commerce catalog with 50+ products. Users can search by Product ID, Product Name (partial match), or Category, and the system displays all product details instantly.

Requirements

  1. Catalog Sheet: 50 products with columns: Product ID, Name, Category, Brand, MRP β‚Ή, Selling Price β‚Ή, Discount %, Rating, Stock, Seller City
  2. Search by ID: =XLOOKUP(SearchID, ProductIDs, AllData, "Product Not Found") β€” returns all columns
  3. Search by Name: =XLOOKUP("*"&SearchTerm&"*", Names, AllData, "No Match", 2) β€” wildcard search
  4. Reverse Lookup: Given a price, find which product matches β€” =XLOOKUP(Price, Prices, Names, "No Match", -1)
  5. Category Filter: Last product in a category using search_mode = -1
  6. Calculate GST (18%) on selling price for electronics, 5% for clothing
  7. Show savings (MRP - Selling Price) and savings percentage

Deliverables

  • Excel file with Catalog and Search Dashboard sheets
  • Three search modes: by ID, by name (partial), by category
  • Auto-calculated GST, savings, and total payable
  • Conditional formatting for out-of-stock items

Interview Q1: Why should new Excel users learn XLOOKUP instead of VLOOKUP?

Answer: XLOOKUP is superior in every way: (1) Looks in any direction, (2) Built-in error handling, (3) Returns multiple columns, (4) Safer default (exact match), (5) Not affected by column insertions, (6) Replaces both VLOOKUP and HLOOKUP. The only reason to learn VLOOKUP is backward compatibility β€” many companies still use Excel 2016/2019 which don't support XLOOKUP.

Interview Q2: Explain the difference between match_mode -1 and 1 in XLOOKUP.

Answer: match_mode -1 finds the "exact match or next smaller value" β€” used for tax slabs, grade boundaries, where you want the bracket floor. match_mode 1 finds the "exact match or next larger value" β€” used for shipping weight tiers or pricing tiers where you want to round up. Example: For weight 3.5 kg, if tiers are 1, 2, 5, 10 kg β€” mode -1 returns the 2 kg tier (β‚Ή50), mode 1 returns the 5 kg tier (β‚Ή80).

Interview Q3: How does XLOOKUP handle the #SPILL! error?

Answer: #SPILL! occurs when XLOOKUP returns multiple values but the target cells aren't empty. Solutions: (1) Clear the cells in the spill range, (2) Use @ operator to return only the first value: =@XLOOKUP(...), (3) Wrap in INDEX to extract a specific element. Understanding spill behavior is essential for working with dynamic arrays in Excel 365.

Teaching sequence: Teach VLOOKUP first (students will encounter it in existing workbooks), then XLOOKUP as "VLOOKUP done right." Run a side-by-side comparison exercise where students solve the same 10 problems with both functions and see the difference in formula complexity. The "look left" example is the biggest aha moment.

πŸ“‹ Chapter 15 Summary

  • XLOOKUP replaces VLOOKUP, HLOOKUP, and many INDEX-MATCH combinations
  • Can look in any direction β€” left, right, horizontal, vertical
  • Built-in if_not_found eliminates the need for IFERROR
  • Returns multiple columns with a single formula (spill range)
  • Match modes: 0 (exact), -1 (next smaller), 1 (next larger), 2 (wildcard)
  • Search modes: 1 (firstβ†’last), -1 (lastβ†’first), 2 (binary asc), -2 (binary desc)
  • Available only in Excel 365 and Excel 2021
  • Nested XLOOKUP enables powerful two-dimensional lookups
Chapter 16

INDEX & MATCH β€” The Power Duo

πŸ† The Formula Every Excel Expert Swears By

Ask any senior data analyst at TCS, Deloitte, or EY which lookup formula they prefer, and 8 out of 10 will say INDEX-MATCH. It's the Swiss Army knife of Excel lookups β€” it can look in any direction, handle multiple criteria, run faster than VLOOKUP on large datasets, and never breaks when you insert or delete columns. If VLOOKUP is a bicycle, INDEX-MATCH is a sports car.

TCSDeloitteEYKPMG
Learning Objectives

What You'll Learn

  • Master the INDEX function independently
  • Master the MATCH function independently
  • Combine INDEX + MATCH for flexible, powerful lookups
  • Understand why INDEX-MATCH is preferred over VLOOKUP in professional settings
  • Perform two-way lookups with INDEX-MATCH-MATCH
  • Use INDEX-MATCH with multiple criteria
  • Build a Dynamic Employee Directory
Theory & Concepts

The INDEX Function

INDEX returns a value from a specific position in a range. Think of it as "give me the value at row X, column Y of this table."

πŸ“ INDEX Syntax
=INDEX(array, row_num, [col_num])
array β€” The range of cells to return from.
row_num β€” The row position in the array.
col_num β€” Optional. The column position (default is 1 for single-column arrays).

INDEX Examples (Standalone)

Using the Employee Database (A1:E6):

Emp ID (A)Name (B)Department (C)Salary β‚Ή (D)City (E)
E1001Amit KumarIT85000Bengaluru
E1002Neha ReddyHR72000Hyderabad
E1003Raj MalhotraFinance95000Mumbai
E1004Kavita NairIT88000Chennai
E1005Suresh JoshiMarketing68000Pune
=INDEX(B2:B6, 3)          β†’ Raj Malhotra (3rd value in the Name column)
=INDEX(A2:E6, 2, 4)       β†’ 72000 (row 2, column 4 of the table = Neha's salary)
=INDEX(A2:E6, 5, 5)       β†’ Pune (row 5, column 5 = Suresh's city)
=INDEX(D2:D6, 1)          β†’ 85000 (1st salary)

The MATCH Function

MATCH searches for a value in a range and returns its position (not the value itself). It answers "WHERE is this value?"

πŸ“ MATCH Syntax
=MATCH(lookup_value, lookup_array, [match_type])
lookup_value β€” The value to search for.
lookup_array β€” A single row or column to search in.
match_type β€” 0 = exact match, 1 = largest value ≀ lookup (sorted asc), -1 = smallest value β‰₯ lookup (sorted desc).

MATCH Examples (Standalone)

=MATCH("E1003", A2:A6, 0)        β†’ 3 (E1003 is in the 3rd position of A2:A6)
=MATCH("Kavita Nair", B2:B6, 0)  β†’ 4 (Kavita is in position 4)
=MATCH("IT", C2:C6, 0)           β†’ 1 (first IT is in position 1)
=MATCH("Finance", C2:C6, 0)      β†’ 3 (Finance is in position 3)
MATCH returns a POSITION, not a VALUE. MATCH("E1003", A2:A6, 0) returns 3, not "E1003" or "Raj Malhotra". It says "the value you're looking for is at position 3 in this range." This position number is then fed into INDEX.

INDEX + MATCH Combined β€” The Magic

Now combine them: MATCH finds the position, INDEX returns the value at that position.

πŸ“ INDEX-MATCH Combined Pattern
=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
Step 1: MATCH finds the position of the lookup value in the lookup_range.
Step 2: INDEX returns the value at that position from the return_range.

Example 1: Look up employee name by ID (same as VLOOKUP)

=INDEX(B2:B6, MATCH("E1003", A2:A6, 0))
  β†’ MATCH finds E1003 at position 3
  β†’ INDEX returns the 3rd value from B2:B6
  β†’ Result: Raj Malhotra

Example 2: LEFTWARD lookup (VLOOKUP can't do this!)

=INDEX(A2:A6, MATCH("Kavita Nair", B2:B6, 0))
  β†’ MATCH finds "Kavita Nair" at position 4 in B2:B6
  β†’ INDEX returns the 4th value from A2:A6
  β†’ Result: E1004

Example 3: Look up salary by city (leftward)

=INDEX(D2:D6, MATCH("Mumbai", E2:E6, 0))
  β†’ MATCH finds "Mumbai" at position 3 in E2:E6
  β†’ INDEX returns 3rd value from D2:D6
  β†’ Result: 95000

Why INDEX-MATCH is Better Than VLOOKUP

AdvantageExplanation
πŸ”„ Look in any directionCan look left, right, up, or down β€” VLOOKUP only looks right
πŸ›‘οΈ Insert-proofUses actual column references (B2:B6), not column index numbers. Inserting columns doesn't break it
⚑ Faster on large dataMATCH only searches the lookup column; VLOOKUP loads the entire table_array into memory
πŸ”§ More flexibleEasy to add multiple criteria, look up max/min, or chain conditions
πŸ“Š Two-way lookupINDEX-MATCH-MATCH naturally handles row + column lookups

Two-Way Lookup: INDEX-MATCH-MATCH

This is the ultimate lookup technique β€” find a value at the intersection of a specific row AND column.

Student Subject Marks (A1:E6):

StudentMathsScienceEnglishHindi
Aarav85927888
Priya91889582
Rohan76698274
Sneha94979190
Vikram68737165
INDEX-MATCH-MATCH β€” Find Rohan's English marks
=INDEX(B2:E6, MATCH("Rohan", A2:A6, 0), MATCH("English", B1:E1, 0))
Step 1: MATCH("Rohan", A2:A6, 0) β†’ 3 (Rohan is in row 3)
Step 2: MATCH("English", B1:E1, 0) β†’ 3 (English is column 3)
Step 3: INDEX(B2:E6, 3, 3) β†’ 82
Result: 82
/* More examples */
=INDEX(B2:E6, MATCH("Sneha",A2:A6,0), MATCH("Hindi",B1:E1,0))     β†’ 90
=INDEX(B2:E6, MATCH("Aarav",A2:A6,0), MATCH("Maths",B1:E1,0))     β†’ 85
=INDEX(B2:E6, MATCH("Priya",A2:A6,0), MATCH("Science",B1:E1,0))   β†’ 88

INDEX-MATCH with Multiple Criteria

Sales Data with Multiple Criteria:

SalespersonRegionProductSales β‚Ή
AmitNorthLaptop450000
PriyaSouthPhone320000
AmitNorthPhone280000
RohanWestLaptop510000
PriyaSouthLaptop390000
AmitEastTablet180000
Find Amit's Phone sales in North region (multiple criteria)
=INDEX(D2:D7, MATCH(1, (A2:A7="Amit")*(B2:B7="North")*(C2:C7="Phone"), 0))
Result: 280000 β€” This is an array formula (Ctrl+Shift+Enter in older Excel). It multiplies three TRUE/FALSE arrays: each condition creates 1s and 0s. The only row where all three are 1 (TRUE) is row 3. MATCH finds position 3, INDEX returns 280000.
In Excel 365, this formula works without Ctrl+Shift+Enter. In older versions (2016, 2019), you MUST press Ctrl+Shift+Enter to make it an array formula. You'll see curly braces {} around the formula in the formula bar.

More Solved Examples

Indian Company Financials

CompanyRevenue β‚ΉCrProfit β‚ΉCrEmployeesSector
TCS24000042500607000IT
Reliance95000073500390000Conglomerate
Infosys18000028900335000IT
HDFC Bank28500051000195000Banking
Wipro11000015200250000IT
/* Basic INDEX-MATCH lookups */
=INDEX(B2:B6, MATCH("Infosys",A2:A6,0))                β†’ 180000 (Revenue)
=INDEX(E2:E6, MATCH("HDFC Bank",A2:A6,0))              β†’ Banking (Sector)

/* Leftward lookup: Find company name by employee count */
=INDEX(A2:A6, MATCH(607000,D2:D6,0))                   β†’ TCS

/* Find the most profitable company */
=INDEX(A2:A6, MATCH(MAX(C2:C6),C2:C6,0))               β†’ Reliance

/* Find the IT company with highest revenue */
=INDEX(A2:A6, MATCH(1,(E2:E6="IT")*(B2:B6=MAX(IF(E2:E6="IT",B2:B6))),0))  β†’ TCS

/* Profit margin calculation */
=INDEX(C2:C6,MATCH("TCS",A2:A6,0))/INDEX(B2:B6,MATCH("TCS",A2:A6,0))*100  β†’ 17.7%

/* Revenue per employee */
=INDEX(B2:B6,MATCH("Wipro",A2:A6,0))*10000000/INDEX(D2:D6,MATCH("Wipro",A2:A6,0))  β†’ β‚Ή44 lakh per employee

Practice Exercises

Exercise 1: Use INDEX-MATCH to find the salary of employee E1004. Answer: =INDEX(D2:D6,MATCH("E1004",A2:A6,0)) β†’ 88000

Exercise 2: Leftward lookup: Find the Emp ID of the person in Mumbai. Answer: =INDEX(A2:A6,MATCH("Mumbai",E2:E6,0)) β†’ E1003

Exercise 3: Two-way lookup: Find Sneha's Hindi marks. Answer: =INDEX(B2:E6,MATCH("Sneha",A2:A6,0),MATCH("Hindi",B1:E1,0)) β†’ 90

Exercise 4: Find the employee with the highest salary. Answer: =INDEX(B2:B6,MATCH(MAX(D2:D6),D2:D6,0))

Exercise 5: Multi-criteria: Find Priya's Laptop sales in South region. Answer: =INDEX(D2:D7,MATCH(1,(A2:A7="Priya")*(B2:B7="South")*(C2:C7="Laptop"),0))

Exercise 6: Find the company with the most employees. Answer: =INDEX(A2:A6,MATCH(MAX(D2:D6),D2:D6,0)) β†’ TCS

Exercise 7: Find the position of "Finance" in the Department column. Answer: =MATCH("Finance",C2:C6,0) β†’ 3

Exercise 8: Use INDEX to get the 4th employee's name and city. Answer: =INDEX(B2:B6,4) and =INDEX(E2:E6,4)

Exercise 9: Find which sector has a company with revenue > β‚Ή5,00,000 Cr. Answer: =INDEX(E2:E6,MATCH(1,(B2:B6>500000)*1,0))

Exercise 10: Calculate the average salary of IT department employees using INDEX-MATCH. Answer: =AVERAGEIF(C2:C6,"IT",D2:D6) or use INDEX-MATCH to first identify IT employees

Assignment

πŸ“‹ Assignment: Indian Cricket Player Stats Lookup

Create a workbook with 20 Indian cricket players (Virat, Rohit, Bumrah, etc.) and columns: Player Name, Role (Batsman/Bowler/All-rounder), Matches, Runs, Wickets, Average, Strike Rate, IPL Team. Use INDEX-MATCH for:

  1. Look up any stat by player name
  2. Find the player with the highest runs (INDEX + MATCH + MAX)
  3. Two-way lookup: select player + stat to display
  4. Multi-criteria: Find the all-rounder with the most wickets

Ctrl + Shift + Enter β€” Enter array formula (needed for multi-criteria INDEX-MATCH in Excel 2016/2019)

F2 β€” Edit cell and see color-coded range references

Ctrl + [ β€” Navigate to precedent cells (trace which cells feed into formula)

Ctrl + ] β€” Navigate to dependent cells (trace which cells use this cell)

MCQ Assessment

INDEX-MATCH Quiz (5 MCQs)

Q1

What does the MATCH function return?

  1. The value that matches
  2. The position (row/column number) of the match
  3. TRUE if the value is found
  4. The cell address of the match
βœ… Answer: (b) β€” MATCH returns the relative position (1, 2, 3...) of the lookup value in the array, not the value itself.
Q2

In =INDEX(C2:C10, 5), what is returned?

  1. The 5th cell of column C (C5)
  2. The 5th value within the range C2:C10 (which is C6)
  3. The value 5
  4. The last 5 values
βœ… Answer: (b) β€” INDEX counts from the start of the specified range. The 5th value in C2:C10 is C6 (C2=1st, C3=2nd, C4=3rd, C5=4th, C6=5th).
Q3

What is the main advantage of INDEX-MATCH over VLOOKUP?

  1. It's easier to learn
  2. It can look in any direction, not just right
  3. It works in all versions of Excel
  4. It automatically sorts data
βœ… Answer: (b) β€” INDEX-MATCH can look left, right, up, or down. VLOOKUP can only return values from columns to the right of the lookup column.
Q4

In INDEX-MATCH-MATCH for a two-way lookup, how many MATCH functions are used?

  1. One
  2. Two
  3. Three
  4. Depends on the data
βœ… Answer: (b) β€” INDEX-MATCH-MATCH uses two MATCH functions: one to find the row position and one to find the column position. INDEX then returns the value at the intersection.
Q5

What is the match_type 0 in MATCH(lookup_value, lookup_array, 0)?

  1. Approximate match (ascending)
  2. Approximate match (descending)
  3. Exact match
  4. Wildcard match
βœ… Answer: (c) β€” match_type 0 means exact match. 1 means largest value ≀ lookup (ascending data), -1 means smallest value β‰₯ lookup (descending data).
Mini Project

πŸš€ Dynamic Employee Directory

πŸ“Š Project: Dynamic Employee Directory β€” Multi-Search System

Problem Statement

Build a comprehensive employee directory for a company with 50+ employees. Users can search by Employee ID, Name, or Department, and the system displays the complete employee profile.

Requirements

  1. Employee Database: 50 employees with: Emp ID, Name, Department, Designation, Salary β‚Ή, City, Join Date, Phone, Email, Manager Name
  2. Search by ID: =INDEX(NameCol, MATCH(SearchID, IDCol, 0))
  3. Search by Name: =INDEX(IDCol, MATCH(SearchName, NameCol, 0)) (leftward lookup)
  4. Search by Department: Show all employees in a department using multiple INDEX-MATCH calls or FILTER
  5. Two-way lookup: Select Employee Name (dropdown) and Field Name (dropdown) β†’ display the value
  6. Multi-criteria search: Find employees in IT Department AND Bengaluru city
  7. Analytics panel: Highest salary employee, lowest salary, average salary by department

Deliverables

  • Excel file with Database, Search Dashboard, and Analytics sheets
  • Three search modes working with dropdowns
  • Department-wise summary with COUNTIF and AVERAGEIF
  • Formatted employee profile card layout
[Screenshot: Dynamic Employee Directory showing search panel with dropdown and auto-populated employee details]

Q1: In an interview, how would you explain INDEX-MATCH to a non-technical person?

Answer: "Imagine a library. MATCH is like looking at the catalog and finding that the book you want is on Shelf 7. INDEX is like going to Shelf 7 and picking up the book. MATCH finds the location, INDEX retrieves the item. Together, they form a complete lookup system β€” you can search any row or column and retrieve data from anywhere in the table."

Q2: When would you use INDEX-MATCH over XLOOKUP?

Answer: (1) When working with Excel 2016/2019 which don't support XLOOKUP. (2) For multi-criteria lookups using array formulas β€” INDEX-MATCH handles this more naturally. (3) When you need to use MATCH independently for dynamic column references. (4) When building formulas that need backward compatibility across different Excel versions in the organization. In Excel 365, XLOOKUP is simpler for basic lookups, but INDEX-MATCH remains relevant for complex scenarios.

Q3: How does INDEX-MATCH handle multiple criteria lookups?

Answer: Use array multiplication inside MATCH: =INDEX(ReturnRange, MATCH(1, (Criteria1Range=Value1)*(Criteria2Range=Value2), 0)). Each condition creates a TRUE/FALSE (1/0) array. Multiplying them creates 1 only where ALL conditions are TRUE. MATCH(1, ..., 0) finds the position of that 1. In older Excel versions, this requires Ctrl+Shift+Enter. In Excel 365, it works as a regular formula.

Q4: Why is INDEX-MATCH faster than VLOOKUP on large datasets?

Answer: VLOOKUP loads the entire table_array into memory for each lookup. If the table is A:Z (26 columns Γ— 1M rows), all 26M cells are loaded. INDEX-MATCH only loads two ranges β€” the lookup range (1 column Γ— 1M rows) and the return range (1 column Γ— 1M rows). This means INDEX-MATCH processes roughly 1/13th the data, making it significantly faster for wide tables.

Q5: Can you explain INDEX-MATCH-MATCH?

Answer: INDEX-MATCH-MATCH is used for two-dimensional lookups where you need to find a value at the intersection of a specific row and column. The formula is: =INDEX(DataRange, MATCH(RowValue, RowHeaders, 0), MATCH(ColValue, ColHeaders, 0)). The first MATCH finds the row number, the second MATCH finds the column number, and INDEX returns the value at that intersection. This is ideal for matrices like student marks across subjects, or sales data across regions and months.

Teaching approach: Teach INDEX and MATCH separately first. Spend 15 minutes on INDEX alone β€” have students extract values by position. Then 15 minutes on MATCH β€” have them find positions. Then combine them and watch the "aha" moment. The two-step mental model (find position β†’ get value) is key. Use the library analogy: MATCH = catalog, INDEX = retrieval.

πŸ“‹ Chapter 16 Summary

  • INDEX returns a value from a specific position in a range
  • MATCH returns the position of a value in a range
  • Combined: =INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
  • Can look in any direction β€” left, right, up, down
  • Insert-proof β€” not affected by column/row insertions
  • Faster than VLOOKUP on large datasets
  • INDEX-MATCH-MATCH enables two-way lookups
  • Multiple criteria supported via array multiplication inside MATCH
  • The preferred lookup method of professional Excel analysts worldwide
Chapter 17

Dynamic Arrays & Spill Functions

⚑ The Biggest Change to Excel in 30 Years

In 2018, Microsoft completely changed how Excel formulas work. Before dynamic arrays, one cell = one value. Now, a single formula can return dozens or hundreds of values that automatically "spill" into adjacent cells. Functions like FILTER, SORT, UNIQUE, SEQUENCE, and SORTBY have made tasks that previously required Pivot Tables, VBA, or complex array formulas trivially simple. At companies like Zomato and Razorpay, data analysts use these functions daily to build live dashboards without pivot tables.

Excel 365ZomatoRazorpaySwiggy
Learning Objectives

What You'll Learn

  • Understand the dynamic array engine and spill range concept
  • Use the spill operator # to reference dynamic results
  • Master 8 dynamic array functions: UNIQUE, SORT, SORTBY, FILTER, SEQUENCE, RANDARRAY, HSTACK, VSTACK
  • Combine dynamic array functions for powerful one-formula solutions
  • Build a dynamic dashboard without Pivot Tables
Theory & Concepts

What Are Dynamic Arrays?

Before Excel 365, if a formula returned multiple values, you had to manually enter it in every cell and press Ctrl+Shift+Enter (CSE). With dynamic arrays, you enter a formula in ONE cell, and the results automatically spill into adjacent cells. The blue border around the spill range shows which cells are controlled by the formula.

[Screenshot: A UNIQUE formula in cell G2 that spills results into G3, G4, G5 with the blue spill border visible]

The Spill Operator (#)

The # (spill reference operator) refers to the entire spill range of a dynamic array formula. If cell G2 contains a UNIQUE formula that spills into G2:G5, then G2# refers to the entire range G2:G5.

=UNIQUE(A2:A10)        β†’ Spills unique values starting from the formula cell
=COUNTA(G2#)           β†’ Counts how many values are in the spill range
=SUM(G2#)              β†’ Sums all values in the spill range
#SPILL! Error: This occurs when cells in the spill range are not empty. Dynamic array results need blank cells to spill into. Solution: Clear all cells below/to the right of your formula that might block the spill.

UNIQUE β€” Extract Unique Values

πŸ“ UNIQUE Syntax
=UNIQUE(array, [by_col], [exactly_once])
array β€” The range to extract unique values from.
by_col β€” Optional. FALSE (default) = compare rows. TRUE = compare columns.
exactly_once β€” Optional. FALSE (default) = all distinct values. TRUE = only values appearing exactly once.

Zomato Orders Data:

Order IDCustomerRestaurantCityAmount β‚Ή
Z001AaravDomino'sMumbai450
Z002PriyaMcDonald'sDelhi380
Z003AaravKFCMumbai520
Z004RohanDomino'sBengaluru350
Z005PriyaSubwayDelhi290
Z006SnehaPizza HutChennai610
Z007AaravBurger KingMumbai420
Z008VikramDomino'sHyderabad380
=UNIQUE(B2:B9)                      β†’ Aarav, Priya, Rohan, Sneha, Vikram (unique customers)
=UNIQUE(D2:D9)                      β†’ Mumbai, Delhi, Bengaluru, Chennai, Hyderabad (unique cities)
=UNIQUE(C2:C9)                      β†’ Domino's, McDonald's, KFC, Subway, Pizza Hut, Burger King
=UNIQUE(B2:B9, , TRUE)              β†’ Rohan, Sneha, Vikram (customers who ordered only ONCE)
=COUNTA(UNIQUE(B2:B9))              β†’ 5 (count of unique customers)

SORT β€” Sort Results

πŸ“ SORT Syntax
=SORT(array, [sort_index], [sort_order], [by_col])
array β€” The range to sort.
sort_index β€” Optional. Column number to sort by (default = 1).
sort_order β€” Optional. 1 = ascending (default), -1 = descending.
by_col β€” Optional. FALSE (default) = sort rows. TRUE = sort columns.
=SORT(A2:E9)                        β†’ Sorts entire table by first column (Order ID ascending)
=SORT(A2:E9, 5, -1)                 β†’ Sorts by Amount (col 5) descending β€” highest order first
=SORT(A2:E9, 4, 1)                  β†’ Sorts by City (col 4) alphabetically
=SORT(UNIQUE(D2:D9))                β†’ Sorted unique cities: Bengaluru, Chennai, Delhi, Hyderabad, Mumbai
=SORT(E2:E9, , -1)                  β†’ Just the amounts sorted: 610, 520, 450, 420, 380, 380, 350, 290

SORTBY β€” Sort by Another Column

πŸ“ SORTBY Syntax
=SORTBY(array, by_array1, [sort_order1], [by_array2], [sort_order2], ...)
array β€” The range to sort (what you see).
by_array β€” The range to sort BY (the sorting key).
sort_order β€” 1 = ascending, -1 = descending. Can specify multiple sort levels.
=SORTBY(B2:B9, E2:E9, -1)           β†’ Customer names sorted by amount (highest spender first): Sneha, Aarav, Aarav...
=SORTBY(A2:E9, D2:D9, 1, E2:E9, -1) β†’ Sort by City ascending, then by Amount descending within each city
=SORTBY(C2:C9, E2:E9, -1)           β†’ Restaurants sorted by order amount: Pizza Hut, KFC, Domino's...

FILTER β€” The Most Powerful Dynamic Array Function

πŸ“ FILTER Syntax
=FILTER(array, include, [if_empty])
array β€” The range to filter.
include β€” A Boolean array (TRUE/FALSE) that defines which rows to include.
if_empty β€” Optional. Value to return if no rows match the filter.

Example 1: Filter orders from Mumbai

=FILTER(A2:E9, D2:D9="Mumbai")
β†’ Returns:
  Z001 | Aarav | Domino's   | Mumbai | 450
  Z003 | Aarav | KFC        | Mumbai | 520
  Z007 | Aarav | Burger King | Mumbai | 420

Example 2: Filter orders above β‚Ή400

=FILTER(A2:E9, E2:E9>400)
β†’ Returns all rows where Amount > 400 (Z001, Z003, Z006, Z007)

Example 3: Multiple criteria (AND β€” multiply conditions)

=FILTER(A2:E9, (D2:D9="Mumbai")*(E2:E9>400))
β†’ Mumbai orders above β‚Ή400: Z001 (450), Z003 (520), Z007 (420)

Example 4: Multiple criteria (OR β€” add conditions)

=FILTER(A2:E9, (D2:D9="Mumbai")+(D2:D9="Delhi"))
β†’ All orders from Mumbai OR Delhi

Example 5: With custom empty message

=FILTER(A2:E9, D2:D9="Jaipur", "No orders from this city")
β†’ "No orders from this city" (no Jaipur orders exist)
FILTER is a game-changer: Before FILTER, extracting rows that meet a condition required Advanced Filter, helper columns, or complex array formulas. Now it's one simple formula. Combine it with SORT and UNIQUE for incredibly powerful one-formula dashboards.

SEQUENCE β€” Generate Number Sequences

πŸ“ SEQUENCE Syntax
=SEQUENCE(rows, [cols], [start], [step])
rows β€” Number of rows to fill.
cols β€” Optional. Number of columns (default = 1).
start β€” Optional. Starting number (default = 1).
step β€” Optional. Increment (default = 1).
=SEQUENCE(5)              β†’ 1, 2, 3, 4, 5 (vertical)
=SEQUENCE(3, 4)           β†’ 3Γ—4 grid: 1-12
=SEQUENCE(5, 1, 100, 10)  β†’ 100, 110, 120, 130, 140
=SEQUENCE(5, 1, 10, -2)   β†’ 10, 8, 6, 4, 2 (countdown)
=SEQUENCE(12, 1, DATE(2025,1,1), 30)  β†’ Dates: Jan 1, Jan 31, Mar 2... (every 30 days)

/* Generate roll numbers */
=SEQUENCE(50, 1, 2001, 1)  β†’ 2001, 2002, 2003... 2050

/* Multiplication table for 7 */
=SEQUENCE(10, 1, 7, 7)    β†’ 7, 14, 21, 28, 35, 42, 49, 56, 63, 70

RANDARRAY β€” Generate Random Data

πŸ“ RANDARRAY Syntax
=RANDARRAY([rows], [cols], [min], [max], [integer])
rows β€” Number of rows (default = 1).
cols β€” Number of columns (default = 1).
min β€” Minimum value (default = 0).
max β€” Maximum value (default = 1).
integer β€” TRUE for whole numbers, FALSE for decimals (default).
=RANDARRAY(5, 1, 1, 100, TRUE)         β†’ 5 random integers between 1-100
=RANDARRAY(10, 3, 30, 100, TRUE)        β†’ 10 students Γ— 3 subjects, marks 30-100
=RANDARRAY(5, 1, 50000, 150000, TRUE)   β†’ 5 random salaries β‚Ή50K-β‚Ή1.5L
=RANDARRAY(1, 6, 1, 49, TRUE)           β†’ 6 random lottery numbers (1-49)
=RANDARRAY(20, 1, 1, 5, TRUE)           β†’ 20 random ratings (1-5 stars)
RANDARRAY is perfect for creating sample datasets for practice. Need 100 student records with random marks? Use =RANDARRAY(100,5,0,100,TRUE) to instantly generate a 100Γ—5 grid of marks between 0 and 100!

HSTACK and VSTACK β€” Combine Arrays

πŸ“ HSTACK (Horizontal Stack) β€” combine side by side
=HSTACK(array1, array2, ...)
Combines multiple arrays horizontally (adds columns). All arrays must have the same number of rows.
πŸ“ VSTACK (Vertical Stack) β€” combine top to bottom
=VSTACK(array1, array2, ...)
Combines multiple arrays vertically (adds rows). All arrays must have the same number of columns.
/* Combine names and salaries side by side */
=HSTACK(B2:B6, D2:D6)              β†’ Two-column result: Name | Salary

/* Stack two city lists on top of each other */
=VSTACK(Sheet1!A2:A10, Sheet2!A2:A15)  β†’ Combined list from two sheets

/* Create a numbered list */
=HSTACK(SEQUENCE(5), B2:B6)         β†’ Row numbers with names: 1|Amit, 2|Neha...

/* Combine unique cities with their counts */
=HSTACK(UNIQUE(D2:D9), COUNTIF(D2:D9, UNIQUE(D2:D9)))
β†’ Mumbai|3, Delhi|2, Bengaluru|1, Chennai|1, Hyderabad|1

Combining Dynamic Array Functions

The true power comes from nesting these functions together:

Combo 1: SORT + UNIQUE β€” Sorted unique list

=SORT(UNIQUE(D2:D9))               β†’ Bengaluru, Chennai, Delhi, Hyderabad, Mumbai

Combo 2: FILTER + SORT β€” Filtered and sorted results

=SORT(FILTER(A2:E9, E2:E9>400), 5, -1)
β†’ Orders above β‚Ή400, sorted by amount descending

Combo 3: UNIQUE + COUNTIF β€” Frequency table

=HSTACK(SORT(UNIQUE(D2:D9)), COUNTIF(D2:D9, SORT(UNIQUE(D2:D9))))
β†’ City | Count β€” a complete frequency table in ONE formula!

Combo 4: FILTER + SORT + UNIQUE β€” Dynamic dropdown source

=SORT(UNIQUE(FILTER(C2:C9, D2:D9="Mumbai")))
β†’ Sorted unique restaurants in Mumbai: Burger King, Domino's, KFC

Combo 5: Complete Summary in One Formula

=HSTACK(
    SORT(UNIQUE(D2:D9)),
    COUNTIF(D2:D9, SORT(UNIQUE(D2:D9))),
    SUMIF(D2:D9, SORT(UNIQUE(D2:D9)), E2:E9)
)
β†’ City | Order Count | Total Revenue β€” complete city-wise summary!
Dynamic arrays only work in Excel 365 and Excel 2021. If you share a workbook with dynamic array formulas to someone using Excel 2019 or earlier, the formulas will show #NAME? errors. Always check compatibility before sharing.

Indian Context Examples

GST Summary by Rate

ProductCategoryPrice β‚ΉGST %
MilkEssential560
RiceEssential1205
LaptopElectronics6500018
PhoneElectronics2500018
CarAutomobile80000028
ACAppliance4500028
BreadEssential400
ShirtClothing12005
/* All products with 18% GST */
=FILTER(A2:D9, D2:D9=18)
β†’ Laptop | Electronics | 65000 | 18
  Phone  | Electronics | 25000 | 18

/* Products under β‚Ή500, sorted by price */
=SORT(FILTER(A2:D9, C2:C9<500), 3, 1)
β†’ Bread|40|0, Milk|56|0, Rice|120|5

/* Unique GST rates, sorted */
=SORT(UNIQUE(D2:D9))    β†’ 0, 5, 18, 28

/* Category-wise product count */
=HSTACK(SORT(UNIQUE(B2:B9)), COUNTIF(B2:B9, SORT(UNIQUE(B2:B9))))
β†’ Appliance|1, Automobile|1, Clothing|1, Electronics|2, Essential|3

/* Total GST amount for electronics */
=SUMPRODUCT(FILTER(C2:C9, B2:B9="Electronics") * FILTER(D2:D9, B2:B9="Electronics")/100)
β†’ 16200

Practice Exercises

Exercise 1: Extract unique restaurant names from the Zomato dataset. Answer: =UNIQUE(C2:C9)

Exercise 2: Sort the orders by amount in descending order. Answer: =SORT(A2:E9,5,-1)

Exercise 3: Filter orders from Delhi only. Answer: =FILTER(A2:E9,D2:D9="Delhi")

Exercise 4: Generate a sequence of 10 even numbers starting from 2. Answer: =SEQUENCE(10,1,2,2)

Exercise 5: Create random test scores (0-100) for 15 students across 4 subjects. Answer: =RANDARRAY(15,4,0,100,TRUE)

Exercise 6: Find orders where Amount > 400 AND City = "Mumbai". Answer: =FILTER(A2:E9,(D2:D9="Mumbai")*(E2:E9>400))

Exercise 7: Create a sorted list of unique cities with order counts using HSTACK. Answer: =HSTACK(SORT(UNIQUE(D2:D9)),COUNTIF(D2:D9,SORT(UNIQUE(D2:D9))))

Exercise 8: Sort customers by their name alphabetically using SORTBY. Answer: =SORTBY(A2:E9,B2:B9,1)

Exercise 9: Filter products with GST rate 0% from the GST dataset. Answer: =FILTER(A2:D9,D2:D9=0)

Exercise 10: Use VSTACK to combine two separate lists of products into one. Answer: =VSTACK(Sheet1!A2:A5,Sheet2!A2:A5)

Assignment

πŸ“‹ Assignment: Automated Sales Report Generator

  1. Create a sales dataset with 100 rows: Salesperson, Region (North/South/East/West), Product, Quantity, Unit Price, Total
  2. Use RANDARRAY to generate realistic random data
  3. Build these dynamic reports using ONLY formulas (no pivot tables):
    • Region-wise total sales: =HSTACK(SORT(UNIQUE(RegionCol)), SUMIF(...))
    • Top 5 salespeople by revenue: =SORT(FILTER(...),col,-1) + take first 5
    • Product-wise unique count and average price
    • Filtered view by region (dropdown selects region)

Ctrl + Shift + Enter β€” Enter legacy array formula (not needed in Excel 365)

Ctrl + T β€” Convert range to Table (great with dynamic arrays)

Ctrl + Space β€” Select entire column in a Table

Ctrl + Shift + L β€” Toggle AutoFilter

MCQ Assessment

Dynamic Arrays Quiz (5 MCQs)

Q1

What does the # (spill reference) operator do?

  1. Converts text to numbers
  2. References the entire spill range of a dynamic array formula
  3. Adds a comment to the formula
  4. Makes the formula absolute
βœ… Answer: (b) β€” The # operator (e.g., G2#) references all cells in the spill range that starts from G2. If UNIQUE spills into G2:G7, then G2# = G2:G7.
Q2

Which function extracts rows that meet a condition, similar to AutoFilter but as a formula?

  1. SORT
  2. UNIQUE
  3. FILTER
  4. SEQUENCE
βœ… Answer: (c) β€” FILTER extracts rows from an array that meet specified conditions, returning results dynamically. It's the formula equivalent of AutoFilter.
Q3

What will =SEQUENCE(5, 1, 10, 3) return?

  1. 10, 13, 16, 19, 22
  2. 1, 2, 3, 4, 5
  3. 10, 11, 12, 13, 14
  4. 3, 6, 9, 12, 15
βœ… Answer: (a) β€” SEQUENCE(5, 1, 10, 3) generates 5 numbers, starting at 10, incrementing by 3: 10, 13, 16, 19, 22.
Q4

What error occurs when a dynamic array result can't spill because the cells are not empty?

  1. #N/A
  2. #VALUE!
  3. #SPILL!
  4. #REF!
βœ… Answer: (c) β€” #SPILL! is a new error type introduced with dynamic arrays. It occurs when the formula needs to output multiple values but the destination cells are occupied.
Q5

Which combination creates a frequency table (unique values + their counts) in a single formula?

  1. FILTER + SORT
  2. UNIQUE + SEQUENCE
  3. HSTACK + UNIQUE + COUNTIF
  4. VSTACK + RANDARRAY
βœ… Answer: (c) β€” =HSTACK(UNIQUE(range), COUNTIF(range, UNIQUE(range))) creates a two-column table with unique values and their counts β€” a complete frequency table in one formula.
Mini Project

πŸš€ Dynamic Dashboard (No Pivot Tables!)

πŸ“Š Project: Swiggy/Zomato Order Analytics Dashboard

Problem Statement

Build a complete analytics dashboard for a food delivery platform using ONLY dynamic array formulas β€” no pivot tables, no VBA, no Power Query. The dashboard should update automatically when new data is added.

Data Sheet (100+ rows)

Columns: Order ID, Customer Name, Restaurant, Cuisine Type, City, Order Amount β‚Ή, Delivery Fee β‚Ή, Rating (1-5), Order Date, Payment Method

Dashboard Components (All using dynamic array formulas)

  1. City Dropdown Filter: Select a city β†’ all data filters instantly
    =FILTER(AllData, CityCol=SelectedCity, "No orders")
  2. Top 10 Restaurants by Revenue:
    =SORT(HSTACK(UNIQUE(RestCol), SUMIF(RestCol, UNIQUE(RestCol), AmountCol)), 2, -1)
    Take first 10 rows
  3. Unique Cuisines Available:
    =SORT(UNIQUE(CuisineCol))
  4. City-wise Summary Table:
    =HSTACK(SORT(UNIQUE(CityCol)), COUNTIF(CityCol, SORT(UNIQUE(CityCol))), SUMIF(CityCol, SORT(UNIQUE(CityCol)), AmountCol))
  5. Payment Method Distribution:
    =HSTACK(UNIQUE(PaymentCol), COUNTIF(PaymentCol, UNIQUE(PaymentCol)))
  6. High-Value Orders (>β‚Ή500):
    =SORT(FILTER(AllData, AmountCol>500), 6, -1)
  7. Random Sample of 10 Orders: Use SORTBY with RANDARRAY for random sampling
    =SORTBY(AllData, RANDARRAY(ROWS(AllData)), 1)
    and take first 10

Deliverables

  • Excel file with Data and Dashboard sheets
  • All 7 dashboard components working with dynamic formulas
  • City filter dropdown using Data Validation + FILTER
  • Professional formatting with conditional formatting for ratings
  • Everything updates automatically when new rows are added to data
[Screenshot: Complete dashboard showing city filter, top restaurants, cuisine list, and summary table β€” all powered by dynamic array formulas]

Q1: What are dynamic arrays in Excel and why are they important?

Answer: Dynamic arrays, introduced in Excel 365, allow a single formula to return multiple values that "spill" into adjacent cells automatically. Before this, each cell needed its own formula. This is revolutionary because: (1) One formula can replace dozens of formulas, (2) Results update automatically when source data changes, (3) Functions like FILTER, SORT, and UNIQUE enable pivot-table-like analysis without pivot tables, (4) The # spill operator lets other formulas reference the dynamic results. They represent the biggest change to Excel's calculation engine in 30 years.

Q2: How would you create a frequency table using dynamic arrays?

Answer: Use =HSTACK(SORT(UNIQUE(range)), COUNTIF(range, SORT(UNIQUE(range)))). UNIQUE extracts distinct values, SORT orders them, COUNTIF counts occurrences of each unique value, and HSTACK combines them side by side. For a more complete table with sums: =HSTACK(SORT(UNIQUE(CatCol)), COUNTIF(CatCol, SORT(UNIQUE(CatCol))), SUMIF(CatCol, SORT(UNIQUE(CatCol)), AmountCol)). This creates a Category | Count | Total table in one formula.

Q3: What is the #SPILL! error and how do you fix it?

Answer: #SPILL! occurs when a dynamic array formula needs to output multiple values but one or more cells in the output range are already occupied. To fix: (1) Click the #SPILL! cell β€” Excel highlights the blocking cells with a purple border, (2) Clear those blocking cells, (3) Move the formula to an area with enough empty space. You can also use the @ (implicit intersection) operator to force single-cell output: =@UNIQUE(range) returns only the first unique value.

Teaching dynamic arrays: Start with SEQUENCE β€” it's the easiest to understand (generates numbers). Then UNIQUE (students see instant results). Then SORT (logical next step). Save FILTER for last as it's the most powerful. The key "aha" moment is when you show HSTACK(UNIQUE(...), COUNTIF(..., UNIQUE(...))) β€” students realize they just built a pivot table with a single formula. Let them experiment with nesting combinations.

πŸ“‹ Chapter 17 Summary

  • Dynamic arrays let one formula return multiple values that spill automatically
  • # (spill operator) references the entire spill range: G2#
  • UNIQUE extracts distinct values from a range
  • SORT sorts results; SORTBY sorts by a different column
  • FILTER extracts rows matching conditions β€” the most powerful function
  • SEQUENCE generates number sequences; RANDARRAY generates random data
  • HSTACK combines arrays horizontally; VSTACK combines vertically
  • Combining these functions creates pivot-table-like dashboards with formulas
  • Available only in Excel 365 and Excel 2021
  • #SPILL! error = destination cells aren't empty
Part IV β€” Complete

Part IV: What You've Mastered

πŸ† Congratulations! You've completed Part IV

You now command the five most powerful lookup and reference techniques in Excel. From the workhorse VLOOKUP to the modern XLOOKUP, from the professional favorite INDEX-MATCH to the revolutionary Dynamic Arrays, you have the tools to find, retrieve, filter, and organize any data in any direction. These are the exact skills that companies like TCS, Infosys, Deloitte, and Flipkart test in interviews.

ChapterFunction(s)Key Skill
13VLOOKUPBasic vertical lookups, exact & approximate match, error handling
14HLOOKUPHorizontal lookups for time-series and cross-tab data
15XLOOKUPModern lookups: any direction, multiple returns, built-in error handling
16INDEX + MATCHProfessional-grade lookups: flexible, fast, multi-criteria
17Dynamic ArraysUNIQUE, SORT, FILTER, SEQUENCE β€” formula-based dashboards

What's Next: Part V β€” Data Analysis & Visualization

In Part V, you'll learn to analyze data with Pivot Tables, create stunning Charts, use Conditional Formatting for visual insights, and master Data Validation for professional forms. You'll also explore What-If Analysis tools like Goal Seek and Scenario Manager. The journey from data entry to data analysis continues!