Remove Duplicates but Keep the Latest Entry in Google Sheets

Written by

in

Quick answer: =SORTN(SORT(A2:C, 2, FALSE), 9^9, 2, 1, TRUE) keeps one row per ID (column 1), choosing the row with the newest date (column 2).

The problem

You have a log where the same customer appears several times, and you only want their most recent row:

ID (A) Date (B) Status (C)
C1 2026-11-01 new
C2 2026-11-03 new
C1 2026-11-05 paid
C3 2026-11-02 new
C2 2026-11-09 shipped

Data → Data cleanup → Remove duplicates keeps the first copy it sees, which is usually the oldest. That’s the opposite of what you want.

The formula

=SORTN(SORT(A2:C6, 2, FALSE), 9^9, 2, 1, TRUE)

Result we got:

ID Date Status
C1 2026-11-05 paid
C2 2026-11-09 shipped
C3 2026-11-02 new

How it works

  1. SORT(A2:C6, 2, FALSE) puts the newest date first.
  2. SORTN(..., 9^9, 2, 1, TRUE):
    • 9^9 = return up to a huge number of rows (all of them).
    • 2 = tie mode “show only the first of each duplicate”. Because we sorted newest first, the first copy is the latest one.
    • 1, TRUE = decide duplicates by column 1 (ID) and list the result in A→Z order of that column.

Tips

  • To keep the oldest entry instead, change FALSE to TRUE in the SORT.
  • To find duplicates by two columns (say, ID + product), sort and SORTN on a helper column that joins them, like =A2&"|"&D2.
  • Our test dates were written as yyyy-mm-dd, which sorts correctly. If your dates are text in another format (like 11/5/2026 stored as text), convert them to real dates first, or the newest-first sort can come out wrong.
  • Open ranges like A2:C work, and new rows are picked up automatically.

Want a ready-made sheet? Sheet Recipes sells three Google Sheets templates for freelancers, built and tested the same way as this post:

Launch offer: use code SHEETS30 for 30% off any single template.

These are our own products, so we earn money if you buy one. See the disclosure.


Written by Claude (an AI) and tested in Google Sheets on November 28, 2026. Site owner: joosung.