DAY 5: Excel - VLOOKUP & XLOOKUP

Guru Charan Pathalla

DAY 5: Excel - VLOOKUP & XLOOKUP

Learning Objectives: - Master VLOOKUP for data lookup - Learn XLOOKUP (Excel 365) - Understand INDEX-MATCH combination - Handle lookup errors gracefully

Topics Covered (60 min):

1. VLOOKUP Fundamentals - Syntax: =VLOOKUP(lookup_value, table_array, col_index, [range_lookup]) - Exact match: range_lookup = FALSE or 0 - Approximate: range_lookup = TRUE or 1 (requires sorted data) - Example: =VLOOKUP(A2, ProductList, 3, 0) - Find price - Limitation: Only looks to the right

2. XLOOKUP (Excel 365) - Syntax: =XLOOKUP(lookup, lookup_array, return_array, [if_not_found]) - Can look left or right - Example: =XLOOKUP(A2, ProductIDs, ProductNames, "Not Found") - More flexible than VLOOKUP

3. INDEX-MATCH Alternative - INDEX: Returns value from position - MATCH: Returns position of value - Combined: =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)) - Works left/right, more powerful

4. Error Handling - =IFERROR(VLOOKUP(...), "Not Found") - =IFNA(XLOOKUP(...), "No Match") - Handles #N/A, #REF!, #VALUE! errors

Video Resources:

  1. Ultimate Guide to VLOOKUP, HLOOKUP and XLOOKUP (39:38)
    https://www.youtube.com/watch?v=2s-zPZKERP4

  2. VLOOKUP and XLOOKUP How to (19:38)
    https://www.youtube.com/watch?v=I1WU5Xorn5k

  3. Advanced Excel Formulas (30:48)
    https://www.youtube.com/watch?v=7cHwPFutzbQ

AI Learning Prompts (Concept Understanding Only):

Understanding VLOOKUP:

Explain Excel VLOOKUP function:

1. What does VLOOKUP stand for and what does it do?
2. Break down the syntax: =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
3. What does each parameter mean?
4. What's the difference between exact match (FALSE/0) and approximate match (TRUE/1)?
5. Why can't VLOOKUP look to the left?
6. Show me examples using employee data (lookup employee name by ID, or salary by name)
7. What are the common errors: #N/A, #REF!, #VALUE!?

Use employee or student data for examples (not sales data).

Understanding XLOOKUP:

Explain XLOOKUP and its advantages:

1. What is XLOOKUP and why is it better than VLOOKUP?
2. What's the syntax: =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found])?
3. How can XLOOKUP look both left and right?
4. How do I handle missing values with the if_not_found parameter?
5. Show me examples using a Product catalog (lookup price by product ID, category by name)
6. Can I use XLOOKUP in Excel 2016? What are alternatives?

Use product inventory or library data for examples.

Understanding INDEX-MATCH:

Explain INDEX and MATCH combination:

1. What does INDEX function do? What does MATCH function do?
2. Why combine them: =INDEX(return_range, MATCH(lookup_value, lookup_range, 0))?
3. How is INDEX-MATCH more flexible than VLOOKUP?
4. Show me the step-by-step breakdown of how INDEX-MATCH works
5. Give examples using student records (lookup grade by student name)

Use school or personnel data for examples.

Understanding Error Handling:

Explain error handling in lookup functions:

1. What causes #N/A errors in VLOOKUP?
2. How does IFERROR work: =IFERROR(formula, value_if_error)?
3. What's the difference between IFERROR and IFNA?
4. Show me how to display "Not Found" instead of #N/A
5. Give examples using membership data (lookup member status, show "Inactive" if not found)

Provide examples with membership or registration data.

Guided Practice (60 min):

📝 How to approach Guided Practice:

  • Follow step-by-step: Work through each exercise in order
  • Use provided resources: Reference the video tutorials and AI prompts if you get stuck
  • Verify your work: Check your results match expected outcomes
  • Take notes: Document key learnings and shortcuts you discover
  • Ask for help: Use AI assistants to clarify concepts you don't understand

Using Superstore Sales dataset with separate reference tables - Excel Practice

📝 Setup Instructions:

  1. Open Excel and create a new workbook "Day05_Practice.xlsx"
  2. Sheet 1 (Orders): Your main order data with columns: OrderID, CustomerID, ProductID, Quantity, Date
  3. Sheet 2 (Customers): Reference table with CustomerID, CustomerName, Region, Email
  4. Sheet 3 (Products): Reference table with ProductID, ProductName, Category, Price
  5. You'll use VLOOKUP/XLOOKUP to pull information from reference tables into the Orders sheet

💡 Why Lookup Functions? Instead of duplicating customer/product details in every order row, we store them once in reference tables and "look them up" when needed. This is database normalization in Excel!

Exercise 1: Your First VLOOKUP - Find Customer Names

Step-by-Step Instructions:

  1. Go to your Orders sheet
  2. Add a column header "Customer Name" (e.g., column E)
  3. Click on cell E2 (first data row)
  4. Type this formula:
    =VLOOKUP(B2, Customers!A:D, 2, FALSE)
    Let's break it down:
    • B2 = Lookup value (CustomerID in current row)
    • Customers!A:D = Table to search (Customers sheet, columns A-D)
    • 2 = Column index (return value from 2nd column = CustomerName)
    • FALSE = Exact match required
  5. Press Enter
  6. Copy the formula down to all order rows (double-click fill handle)

💡 Tips:

  • VLOOKUP always searches the FIRST column of your range
  • FALSE = exact match (use this for IDs), TRUE = approximate match (for ranges)
  • Use absolute references if needed: $A$2:$D$100
  • The "V" stands for "Vertical" - searches down columns

✅ Expected Result: Customer names appear next to their IDs in every order row

SQL Equivalent - VLOOKUP as JOIN

In SQL, VLOOKUP is done using JOIN. This query joins Orders with Customers to get customer names.

Tip: Press Ctrl+Enter to run

Exercise 2: VLOOKUP Product Prices

Step-by-Step Instructions:

  1. Add a "Unit Price" column in your Orders sheet (e.g., column F)
  2. In F2, type:
    =VLOOKUP(C2, Products!A:D, 4, FALSE)
    • C2 = ProductID to look up
    • Products!A:D = Product reference table
    • 4 = Return value from 4th column (Price)
  3. Copy down to all rows
  4. Add a "Total Price" column (G): =F2*D2 (Unit Price × Quantity)
  5. Copy this formula down too

🔍 Understanding Column Index:

  • If your Products table is: A=ProductID, B=ProductName, C=Category, D=Price
  • Column index 1 = ProductID, 2 = ProductName, 3 = Category, 4 = Price
  • To get category instead: =VLOOKUP(C2, Products!A:D, 3, FALSE)

✅ Expected Result: Each order shows unit price and calculated total price

SQL Equivalent - VLOOKUP with Calculation

Join with Products table to get prices, then calculate total price using Quantity.

Tip: Press Ctrl+Enter to run

Exercise 3: Handle Errors with IFERROR

Step-by-Step Instructions:

  1. VLOOKUPs return #N/A error when lookup value isn't found
  2. Wrap your VLOOKUP with IFERROR to handle this gracefully:
    =IFERROR(VLOOKUP(B2, Customers!A:D, 2, FALSE), "Customer Not Found")
  3. Now if a CustomerID doesn't exist, you see "Customer Not Found" instead of #N/A
  4. Try it: Temporarily change a CustomerID to "999999" and watch the formula handle it
  5. Change it back after testing

💡 Error Handling Best Practices:

  • Always wrap VLOOKUPs in IFERROR for user-friendly error messages
  • Alternative messages: "Not Found", "N/A", "Check Data", or even "" (blank)
  • Syntax: =IFERROR(your_formula, value_if_error)

✅ Expected Result: Clean data with user-friendly messages instead of #N/A errors

SQL Equivalent - Error Handling with COALESCE

Use COALESCE or IFNULL to provide default values when lookup fails (like IFERROR in Excel).

Tip: Press Ctrl+Enter to run

Exercise 4: XLOOKUP - The Modern Alternative (Excel 365)

Step-by-Step Instructions:

  1. XLOOKUP is newer, more flexible than VLOOKUP
  2. Add a "Region" column (e.g., column H)
  3. In H2, type:
    =XLOOKUP(B2, Customers!A:A, Customers!C:C, "Not Found")
    Syntax:
    • B2 = Lookup value (CustomerID)
    • Customers!A:A = Where to search (CustomerID column)
    • Customers!C:C = What to return (Region column)
    • "Not Found" = Built-in error handling!
  4. Press Enter and copy down

🎯 XLOOKUP Advantages over VLOOKUP:

  • Can search any column (not just first column)
  • Can return columns to the LEFT of lookup column
  • Built-in error handling (no IFERROR needed)
  • Can search from bottom-up
  • Generally faster and more intuitive

⚠️ Note: XLOOKUP only works in Excel 365/2021+. If you don't have it, continue using VLOOKUP or INDEX-MATCH

✅ Expected Result: Region data pulled from Customers table with built-in error handling

SQL Equivalent - XLOOKUP as JOIN with COALESCE

XLOOKUP's built-in error handling is similar to LEFT JOIN with COALESCE in SQL.

Tip: Press Ctrl+Enter to run

Exercise 5: INDEX-MATCH - The Flexible Power Combo

Step-by-Step Instructions:

  1. INDEX-MATCH is more flexible than VLOOKUP and works in all Excel versions
  2. Add a "Product Category" column (e.g., column I)
  3. Type this formula:
    =INDEX(Products!C:C, MATCH(C2, Products!A:A, 0))
    Breaking it down:
    • MATCH(C2, Products!A:A, 0) finds the row number where C2 (ProductID) appears in Products column A
    • INDEX(Products!C:C, ...) returns the value from that row in column C (Category)
    • 0 = exact match
  4. Wrap in IFERROR for safety:
    =IFERROR(INDEX(Products!C:C, MATCH(C2, Products!A:A, 0)), "Not Found")
  5. Copy down to all rows

💡 Why INDEX-MATCH?

  • More flexible than VLOOKUP (can look left, not just right)
  • Can change column references without rewriting formulas
  • Works in all Excel versions (unlike XLOOKUP)
  • Often faster with large datasets

✅ Expected Result: Product categories populated using INDEX-MATCH

SQL Equivalent - INDEX-MATCH as JOIN

INDEX-MATCH in Excel is just another way to do lookups. In SQL, it's still a JOIN operation.

Tip: Press Ctrl+Enter to run

🎯 Practice Goal Checkpoint:

By completing these 5 exercises, you should now be able to:

  • Use VLOOKUP to retrieve data from reference tables
  • Understand VLOOKUP syntax and column index numbers
  • Handle lookup errors gracefully with IFERROR
  • Use XLOOKUP (Excel 365) with built-in error handling
  • Apply INDEX-MATCH for flexible lookups
  • Choose the right lookup function for your situation

Key Insight: Lookup functions connect related data across tables - this is how databases work! You're learning relational data concepts in Excel.

Comparison Guide:

  • VLOOKUP: Classic, simple, but limited (only looks right)
  • XLOOKUP: Modern, powerful, easy - use if available
  • INDEX-MATCH: Most flexible, works everywhere, steeper learning curve

Take a 5-minute break, then move on to Independent Practice!

Independent Practice (60 min):

💡 Hints for Independent Practice:

  • Start simple: Begin with basic variations before attempting complex modifications
  • Break it down: Divide complex problems into smaller, manageable steps
  • Test incrementally: Verify each step works before moving to the next
  • Use documentation: Refer to official docs or tutorials when needed
  • Experiment: Try different approaches to find what works best
  1. Create order detail report using VLOOKUP to add customer information
  2. Add product names to orders using XLOOKUP
  3. Calculate extended price: Quantity × VLOOKUP(Unit Price)
  4. Use INDEX-MATCH to find discount rate
  5. Lookup shipping cost by region
  6. Multi-criteria lookup using XLOOKUP
  7. Create customer summary with multiple VLOOKUPs
  8. Handle errors: Show “Unknown” for missing data

Daily Assignment (60 min):

Expected Outcomes:

✓ Perform data lookups efficiently
✓ Choose appropriate lookup function for each scenario
✓ Handle lookup errors gracefully
✓ Submit: Day05_Excel_Practice.xlsx

📝 Day 5 Quick Quiz - Test Your Knowledge!

Q1. What does VLOOKUP do?

Q2. In VLOOKUP, what does the 4th argument (range_lookup) control?

Q3. What's a key advantage of XLOOKUP over VLOOKUP?

Q4. What error does VLOOKUP return when it can't find a match?

Q5. In =VLOOKUP(A1, B1:D10, 3, FALSE), what does 3 represent?


Have feedback or questions?