# How to get the most recent entry for every customer in Excel

Keep the rows whose date is that customer's latest: `=SORT(FILTER(A2:C11,B2:B11=MAXIFS(B2:B11,A2:A11,A2:A11)))`.

**Excel:** `=SORT(FILTER(A2:C11,B2:B11=MAXIFS(B2:B11,A2:A11,A2:A11)))` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** `=SORT(FILTER(A2:C11,COUNTIFS(A2:A11,A2:A11,B2:B11,">"&B2:B11)=0))`

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Customer | Date | Amount |  | Latest order per customer |
| Contoso | 2026-04-02 | 420 |  |  |
| Fabrikam | 2026-04-05 | 310 |  |  |
| Contoso | 2026-04-16 | 760 |  |  |
| Northwind | 2026-04-12 | 150 |  |  |
| Fabrikam | 2026-04-19 | 230 |  |  |
| Litware | 2026-04-08 | 980 |  |  |
| Contoso | 2026-04-09 | 545 |  |  |
| Northwind | 2026-04-26 | 615 |  |  |
| Fabrikam | 2026-04-14 | 390 |  |  |
| Litware | 2026-04-30 | 205 |  |  |

Formula in E2: `=SORT(FILTER(A2:C11,B2:B11=MAXIFS(B2:B11,A2:A11,A2:A11)))`

Result (spills 4 × 3): Contoso, 4/16/2026, $760; Fabrikam, 4/19/2026, $230; Litware, 4/30/2026, $205; Northwind, 4/26/2026, $615

## How it works

`MAXIFS(B2:B11,A2:A11,A2:A11)` works out, for every row, the latest date of that row's customer. FILTER keeps the rows whose own date equals it, one per customer, and SORT puts them in customer order.

The Google Sheets version keeps the rows for which COUNTIFS finds no later order from the same customer, which is the same set of rows.

## Other ways

- `=FILTER(A2:C11,B2:B11=MAXIFS(B2:B11,A2:A11,A2:A11))`: Without SORT the rows stay in their original order. (Original order: Contoso, Fabrikam, Northwind, Litware.)

## Common mistakes

- If a customer has two orders on the latest date, both rows are kept. Add a time or an order number to break ties.
- MAXIFS with a range as its criteria needs Excel 2021 or Microsoft 365.

## Questions

**How do I get the first order per customer instead?**

Use MINIFS: `=SORT(FILTER(A2:C11,B2:B11=MINIFS(B2:B11,A2:A11,A2:A11)))`.

**How do I do it for one customer only?**

Use XLOOKUP with MAXIFS; see the latest status for an ID.

**Is there a shortcut in Google Sheets?**

Sort newest first and keep the first row per customer with SORTN: `=SORTN(SORT(A2:C11,2,FALSE),9^9,2,1,TRUE)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/latest-entry-for-every-customer
