Ravindra BagaleCourses & study guides मराठी Track your progress

4. Lookup Functions

4.7 XLOOKUP Match Modes, Search Modes and Multiple Returns

XLOOKUP search mode (last match) with example — in 30 seconds

What: The 6th argument of XLOOKUP sets the search direction. -1 searches from the bottom, so you get the latest match.

Why: "What was Zoya's last order?" A normal lookup gives her first order, which is old news.

Tiny example: Zoya ordered ₹120 and later ₹450. Search mode -1 returns ₹450.

First look at the data (before → after):

XLOOKUP search mode (last match) with example: before and after tables, fictional FreshGo Maharashtra data

Expected result — First vs last match

Formula ends with Result (₹)
…Orders[Amount]) (default) 120
…, , 0, -1) 450

About this data: Teaching sample for a fictional shop “Orbit Logistics”. Figures and names (e.g. Aamir Khan) are made up for this lesson on xlookup match modes search modes and multiple.

Before table and formula as text

Before — Orders table (sorted by date)

Date Customer Amount (₹)
03-11-2026 Zoya 120
04-11-2026 Amir 300
07-11-2026 Zoya 450
08-11-2026 Ravina 180

About this data: Demo table only — not real customer or company data. Built to practise xlookup match modes search modes and multiple.

Formula / click path

=XLOOKUP("Zoya", Orders[Customer], Orders[Amount])   → first match
=XLOOKUP("Zoya", Orders[Customer], Orders[Amount], , 0, -1)   → last match

Do it step by step:

  1. Make sure the table is sorted by date, oldest first.
  2. Type =XLOOKUP("Zoya", Orders[Customer], Orders[Amount]). You get the first order.
  3. Now type =XLOOKUP("Zoya", Orders[Customer], Orders[Amount], , 0, -1).
  4. The two commas skip if_not_found. 0 means exact match. -1 means search from the last row.
  5. Check: 120 and 450.
Argument Value Meaning
match_mode 0 (default) Exact match
-1 Exact, else next smaller item
1 Exact, else next larger item
2 Wildcard match (*, ?, ~)
search_mode 1 (default) First to last
-1 Last to first (find the latest entry)
2 / -2 Binary search on sorted data (ascending / descending)

About this data: Made-up rows so you can copy the pattern for xlookup match modes search modes and multiple. Currencies may use ₹, £, € or $.

Worked examples

Need Formula
Latest order amount of customer Zoya (Orders sorted by date) =XLOOKUP("Zoya", Orders[Customer], Orders[Amount], , 0, -1)
Store whose area contains "Road" =XLOOKUP("*Road*", Stores[Area], Stores[Store ID], , 2) → BLK-NSK-01 (College Road)
Delivery fee slab (see 4.9) =XLOOKUP(G2, FeeSlabs[Min Order], FeeSlabs[Fee], , -1)

About this data: Fictional worksheet used in class. Safe to edit; nothing here is live production data.

Multiple returns. If return_array has several columns, XLOOKUP spills them all:

=XLOOKUP(G2, Stores!$A$2:$A$8, Stores!$C$2:$E$8)

→ City, Area and City Manager in three adjacent cells (e.g. Nashik | College Road | Zoya).

Ravindra Bagale's Tip

For a wildcard, many students just write "*Road*" and don't give match_mode 2 – then XLOOKUP searches literally for "Road" and finds nothing. In VLOOKUP wildcards work automatically; in XLOOKUP you need match_mode = 2 – keep that in mind. When returning multiple columns, keep the space to the right empty, otherwise you get #SPILL!.

Practice task

Return the last delivery time recorded for BLK-PUN-01. Return City, Area and Manager in one XLOOKUP. Find the first product whose name contains "Grapes".

Loading practice tasks...

  1. First order of Zoya (Easy): Find the Amount of Zoya's first order.
  2. Amir's order (Easy): Find the Amount for "Amir".
  3. Tracking: first scan (Easy): Find the first Status of AWB-7001.
  4. Last order of Zoya (Medium): Find the Amount of Zoya's last order.
  5. Date of last order (Medium): Find the Date of Zoya's last order.
  6. Tracking: latest status (Medium): Find the latest Status of AWB-7001.
  7. Tracking: latest for AWB-7002 (Medium): Find the latest Status of AWB-7002.
  8. Tracking: date delivered (Medium): Find the Date of the latest scan of AWB-7001.
  9. No order message (Hard): Find the Amount for "Raja". If not found show "No order".
  10. Tracking: no scan yet (Hard): Find the latest Status of AWB-7009. Show "No scan yet" if missing.

Quick revision cards

Three standalone cards. Each one explains the idea with its own example. Scan the QR to open this lesson.

Revision card 1: What is Xlookup Match Modes Search Modes And Multiple?
Card 1: What is Xlookup Match Modes Search Modes And Multiple? · Download PNG
Revision card 2: Tiny example — Xlookup Match Modes Search Modes And Multiple
Card 2: Tiny example — Xlookup Match Modes Search Modes And Multiple · Download PNG
Revision card 3: Checklist — Xlookup Match Modes Search Modes And Multiple
Card 3: Checklist — Xlookup Match Modes Search Modes And Multiple · Download PNG