← All how-to recipes

How to find the earliest (or latest) date per category

✓ Verified in LibreOffice 25.8.7.3

The first order date per customer, the last activity per project — a min/max date filtered by group.

The formula

AppFormulaNotes
Excel=MINIFS(B2:B6,A2:A6,"East")A = category, B = dates. MAXIFS for the latest. Format the result as a date.
Google Sheets=MINIFS(B2:B6,A2:A6,"East")Identical.
LibreOffice Calc=MINIFS(B2:B6,A2:A6,"East")Identical.

How it works

Because dates are just numbers, MINIFS finds the smallest (earliest) date among rows matching the category: the three East rows have dates 46229, 46210 and 46250, so the earliest is 46210 (format the cell as a date to read it). MAXIFS gives the latest date the same way. This is the standard 'first/last event per group' calculation — first purchase per customer, most recent login per user. MINIFS/MAXIFS need Excel 2019+ (they're in Google Sheets and LibreOffice); on older Excel use a MIN(IF(...)) array formula. To also return WHAT happened on that date, feed the result into INDEX/MATCH.

Verified, not just documented

We ran =MINIFS(B2:B5,A2:A5,"East") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 46210 — exactly the expected result. Every formula here is confirmed by actually executing it.