# How to get the last 3 entries for a customer in Excel

Filter the customer's rows and take the last three: `=TAKE(FILTER(A2:C12,B2:B12=F1),-3)`.

**Excel:** `=TAKE(FILTER(A2:C12,B2:B12=F1),-3)` (Excel 2024 and Microsoft 365)

**Google Sheets:** `=FILTER(A2:C12,B2:B12=F1,COUNTIFS(B2:B12,F1,ROW(B2:B12),">"&ROW(B2:B12))<3)`

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Customer | Amount |  | Customer | Contoso |
| 2026-04-02 | Contoso | 420 |  | Last 3 orders |  |
| 2026-04-05 | Fabrikam | 310 |  |  |  |
| 2026-04-09 | Contoso | 980 |  |  |  |
| 2026-04-12 | Northwind | 150 |  |  |  |
| 2026-04-16 | Contoso | 760 |  |  |  |
| 2026-04-19 | Fabrikam | 230 |  |  |  |
| 2026-04-23 | Contoso | 545 |  |  |  |
| 2026-04-26 | Northwind | 615 |  |  |  |
| 2026-04-30 | Contoso | 205 |  |  |  |
| 2026-05-03 | Fabrikam | 390 |  |  |  |
| 2026-05-06 | Northwind | 480 |  |  |  |

Formula in E3: `=TAKE(FILTER(A2:C12,B2:B12=F1),-3)`

Result (spills 3 × 3): 4/16/2026, Contoso, $760; 4/23/2026, Contoso, $545; 4/30/2026, Contoso, $205

## How it works

FILTER returns all five Contoso orders in date order. TAKE with a negative count takes rows from the end, so `-3` keeps the last three. Google Sheets has no TAKE; there, a second condition keeps rows that have fewer than 3 later Contoso orders below them, which is the same three rows.

## Other ways

- `=TAKE(SORT(FILTER(A2:C12,B2:B12=F1),1,-1),3)`: Sorts newest first before taking three, so it works even if the list isn't in date order. (Newest first: April 30, 23, 16.)
- `=TAKE(FILTER(A2:C12,B2:B12=F1),3)`: A positive count takes the first rows instead. (The first three orders: April 2, 9 and 16.)

## Common mistakes

- TAKE needs Excel 2024 or Microsoft 365. In Excel 2021, use `INDEX(FILTER(…),SEQUENCE(3,1,ROWS(FILTER(…))-2),{1,2,3})` or sort newest first.
- With fewer than three orders, TAKE returns the ones that exist.
- "Last" means last in the list. If rows aren't added in date order, sort by date first.

## Questions

**How do I total the last 3 orders?**

Take the amounts and add them: `=SUM(TAKE(FILTER(C2:C12,B2:B12=F1),-3))`.

**How do I make the 3 a cell?**

Use a negative cell reference: `=TAKE(FILTER(A2:C12,B2:B12=F1),-H1)`.

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/last-3-entries-for-a-customer
