About this exercise
A 430-row dataset on 2 sheets, one answer cell, about 10 minutes. Graded in your browser: the value and the formula behind it, with feedback that names the fix.
How to solve it
- Customers!C2
=MAXIFS(Orders!$B$2:$B$401,Orders!$C$2:$C$401,A2)
Excel stores a date as a serial number — the count of days since 1 January 1900 — so "the most recent date" is simply the largest number. MAXIFS(dates, customers, A2) takes the maximum of the dates on rows whose customer equals the name in A2, which is the last order whatever the sort order of the sheet. XLOOKUP with search mode −1 reaches the same cell differently: it scans the customer column from the bottom and returns the date of the first match it meets, which is the latest order only because the Orders sheet is sorted oldest-first.
Pitfall 1: XLOOKUP(…,-1) depends on the sort order; a sheet sorted by order ID or by customer breaks it silently, MAXIFS does not care. Pitfall 2: MAXIFS returns 0 for a customer with no orders, which a date format shows as 1900-01-00; XLOOKUP returns #N/A. Wrap either in IF or IFNA when the list can contain prospects. Pitfall 3: the result is a serial number until the cell carries a date format — the grader compares numbers, so an unformatted correct answer still passes, but the report reader will not understand 46,250. Pre-2019 alternatives: =MAX(IF(Orders!$C$2:$C$401=A2,Orders!$B$2:$B$401)) entered with Ctrl+Shift+Enter, =LOOKUP(2,1/(Orders!$C$2:$C$401=A2),Orders!$B$2:$B$401) (the classic "last match" trick, sort-order dependent) and =AGGREGATE(14,6,Orders!$B$2:$B$401/(Orders!$C$2:$C$401=A2),1). Performance: MAXIFS scans 400 rows for each of 30 customers — trivial; on a million-row log a pivot table with Max of Order date is the better tool.
Other ways that work
- =XLOOKUP(A2,Orders!$C$2:$C$401,Orders!$B$2:$B$401,,0,-1) — Excel 365; search mode −1 = last to first, relies on the date sort
- =MAX(IF(Orders!$C$2:$C$401=A2,Orders!$B$2:$B$401)) — array formula (Ctrl+Shift+Enter before Excel 365)
- =LOOKUP(2,1/(Orders!$C$2:$C$401=A2),Orders!$B$2:$B$401) — the classic last-match trick; also sort-order dependent
- =AGGREGATE(14,6,Orders!$B$2:$B$401/(Orders!$C$2:$C$401=A2),1) — LARGE(…,1) ignoring the errors produced by non-matching rows
Common mistakes
A plain lookup: =XLOOKUP(A2,Orders!$C$2:$C$401,Orders!$B$2:$B$401) or a VLOOKUP returns the first matching row, which on a sheet sorted oldest-first is the customer's earliest order of the year, not the last.
How we grade
Any formula that produces the right result is accepted, unless the task names a function: then another function earns half credit. We compare values with a small tolerance and ignore case and spaces in text. A correct number typed by hand instead of a formula earns half credit. Multi-cell tasks earn full credit at 100% of cells, half credit from 50%. Where it matters, we also change an input cell on a copy of your sheet and check that your formula follows.
Answers computed with Excel 365 rules and checked in our grading engine on November 16, 2026. Author: GridBelt team.