WorkbookLogic
FormulaFreeLookupintermediateXLOOKUPMAXCOUNTIFIFROUNDDATE

XLOOKUP Latest by Date

By WorkbookLogic

Return the most recent value for one selected item from an unsorted history by filtering its dates, finding the maximum eligible date, and retrieving the aligned result.

ExcelLast reviewed Sep 11, 2026
xlookup-latest-by-date-v1.0.0.xlsxFree
XLOOKUP Latest by Date, Formula Review
Filter dates by item, take the latest matching date, and return its aligned value from unsorted data.
Unsorted price history and filtered datesCriteria and function review
ItemDatePrice ($)Date when selectedSelected itemBelt
BagFeb 5, 2025$42.10Missing item exampleScarf
BeltMar 12, 2025$28.50Mar 12, 2025
CapJul 25, 2025$19.90(unresolved)StepFormula syntaxResult
BeltJan 10, 2025$24.50Jan 10, 2025MAX all datesMAX($B$12:$B$21)Jul 25, 2025
BagJun 2, 2025$44.20(unresolved)MAX filtered datesMAX(($A$12:$A$21=$J$11)*$B$12:$B$21)Jun 18, 2025
CapApr 8, 2025$18.75(unresolved)Latest priceXLOOKUP(MAX($D$12:$D$21),$D$12:$D$21,$C$12:$C$21,"Not found",0)$31.75
BeltJun 18, 2025$31.75Jun 18, 2025Matching rowsCOUNTIF($A$12:$A$21,$J$11)3
BagJan 22, 2025$40.00(unresolved)Missing itemIF(COUNTIF($A$12:$A$21,$J$12)=0,"Not found",XLOOKUP(MAX(($A$12:$A$21=$J$12)*$B$12:$B$21),($A$12:$A$21=$J$12)*$B$12:$B$21,$C$12:$C$21,"Not found",-1))Not found
CapMay 15, 2025$19.25(unresolved)
BagMar 30, 2025$43.00(unresolved)
Reliability checks
Filtered maximum date equals 18-Jun-2025 for BeltOK
Latest price returned from the filtered date array equals $31.75OK
Selected item has at least one matching observationOK

Overview

Return the value attached to the latest dated observation for one selected item, even when the history is unsorted. The example produces a single price after restricting the eligible dates to the chosen product.

When to use it

Use it for the latest product price, exchange rate, forecast version, valuation mark, inventory cost, or contract rate when one item has several dated records and physical row order cannot be trusted.

When not to use it

Use reverse-search XLOOKUP only when rows are reliably ordered oldest to newest. Use MAXIFS plus a separate lookup when displaying the latest date as an explicit audit step matters. Use FILTER and SORT when users need multiple recent observations rather than one result.

Problem

A last-row lookup can return an older record from an unsorted history. Taking MAX across the full date column can also select another product’s date. The latest date must first be limited to rows belonging to the selected item.

Inputs

Input

Location

Sample

Selected item

Combined Example!J11

Belt

Source data

The synthetic history in A12:C21 includes ten item, date, and price rows. Its three Belt records are:

Item

Date

Price

Belt

12-Mar-2025

$28.50

Belt

10-Jan-2025

$24.50

Belt

18-Jun-2025

$31.75

Dates must be genuine Excel dates, not text. Item, date, and price ranges must have identical row boundaries. Sorting is unnecessary; duplicate item-date pairs remain ambiguous.

Calculations

  1. Compare each source item with the selected item.
  2. Multiply that Boolean array by the date array, preserving matching date serials and converting nonmatches to zero.
  3. Take MAX to identify the latest matching date.
  4. Look up that date in the filtered array and return the aligned price.
  5. Count matching items first so absence produces Not found instead of treating zero as a valid date.

Outputs

For Belt, the workbook returns 18-Jun-2025, $31.75, and 3 matching observations. The result is one currency value; the separate date and count make the selected population visible. A missing item returns Not found.

Formula map

=IF(COUNTIF($A$12:$A$21,$J$11)=0,"Not found",XLOOKUP(MAX(($A$12:$A$21=$J$11)*$B$12:$B$21),($A$12:$A$21=$J$11)*$B$12:$B$21,$C$12:$C$21,"Not found",-1))

The absolute source ranges and criterion cell keep the calculation stable when copied. The two identical Boolean-date arrays derive and then locate the eligible maximum. Search mode -1 allows exact or next-smaller matching; here MAX comes from that same array, so an exact date is present whenever the item exists.

Model checks

The example workbook confirms that the filtered maximum equals 18-Jun-2025, the returned price equals $31.75, and the selected item has at least one observation. Each supplied check returns OK.

Edge cases

  • One observation returns that row’s value.
  • No matching item returns Not found because COUNTIF runs before the lookup.
  • Duplicate rows on the latest date are ambiguous; XLOOKUP returns the first eligible price.
  • Text dates do not behave like date serials and can invalidate MAX.
  • A blank criterion may match blank item cells inside the bounded range.
  • Source errors propagate; the formula does not suppress them.

Common errors

  • Using the last physical row: an older observation may be returned. Calculate the filtered maximum date.
  • Taking MAX before filtering: another item’s date becomes the key. Apply the item comparison inside MAX.
  • Misaligning arrays: the returned price can come from the wrong row. Keep every range on rows 12:21.
  • Skipping the missing-item guard: an all-zero filtered array is treated as a lookup target. Test the item count first.

Example

Belt’s three dates are 10-Jan, 12-Mar, and 18-Jun-2025. After other products’ dates become zero, MAX returns 18-Jun-2025. That date aligns with $31.75, which XLOOKUP returns. The table-wide maximum is 25-Jul-2025 for Cap, confirming why the item filter is necessary.

Example workbook

Edit the cream item criterion in Combined Example!J11 or the history in A12:C21. The visible helper in column D, latest date, price, count, formula, and three checks update. Formula Review also demonstrates missing item Scarf.

Key takeaway

Filter the date array before taking its maximum; “latest” must be defined within the selected item’s records, not by row position or the entire history.