Latest order per customer, not the first (XLOOKUP)
The problem
Problem statement
Sales asks for the most recent order amount for the customer in E2. The log in A2:C7 is in date order, so the newest row for a customer is the last one that mentions them. Put that amount in the Latest amount cell F2.
A normal lookup returns the first match — you need the last one.
Problem data
Show the sheet as a table (selectable, copyable)
| A | B | C | E | F | |
|---|---|---|---|---|---|
| 1 | Customer | Order date | Amount | Customer | Latest amount |
| 2 | Ada | 2026-01-05 | 100 | Ada | |
| 3 | Ben | 2026-01-12 | 60 | ||
| 4 | Ada | 2026-01-20 | 150 | ||
| 5 | Ada | 2026-02-02 | 250 | ||
| 6 | Ben | 2026-02-10 | 90 | ||
| 7 | Cleo | 2026-01-15 | 70 |
Notes
XLOOKUP's sixth argument is the search mode: 0 searches first to last, -1 searches last to first, which turns it into a last-match lookup. The older trick is LOOKUP(2, 1/(keys=target), values): the division turns matches into 1s and misses into #DIV/0!, and LOOKUP finds the last 1. VLOOKUP cannot do this at all without helper columns.
How to approach
Your answer goes in F2. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.
- Target cell is F2
- A default lookup finds the first Ada, which is 100
XLOOKUPhas a search mode argument — search backwards- Shape:
=XLOOKUP(?, ?, ?, ?, 0, -1)
Official solutions
Show 2 solutions — try it yourself first
Approach 1: XLOOKUP with search mode -1
=XLOOKUP(E2, $A$2:$A$7, $C$2:$C$7, "none", 0, -1)
Searching last to first from the bottom of the log finds Ada's newest row (2026-02-02) and returns 250. Ada appears three times; the other two return 100 and 150.
Approach 2: the LOOKUP(2, 1/(...)) trick
=LOOKUP(2, 1/($A$2:$A$7=E2), $C$2:$C$7)
1/(keys=target) produces 1 for matching rows and #DIV/0! for the rest; LOOKUP ignores errors and returns the value at the last 1. It works in every Excel version, which is why finance models still use it.
Function guide
FAQ
How do I get the last matching row instead of the first?
=XLOOKUP(key, keys, values, "", 0, -1) searches last to first. Without XLOOKUP, use =LOOKUP(2, 1/(keys=key), values).
Why does VLOOKUP give me an old order?
VLOOKUP stops at the first match. With multiple rows per customer it returns the oldest one in the log, not the newest.