Data Cleaning: Keep Only The Most Recent Duplicate Record

Excel Formulas › Data Cleaning

All versions

A customer list re-exported every month often contains the same customer ID multiple times — once per export where their record was included, each with a different "last updated" date. Deduplicating by keeping just the first occurrence throws away the most current information. This recipe flags the row with the latest date for each key as the one to keep, and every earlier duplicate as superseded.


Quick formula: Compare each row's date to the latest date recorded for that same key with MAXIFS:
=IF(B2=MAXIFS($B$2:$B$6,$A$2:$A$6,A2),"Keep","Superseded")

Customer C-104 appears three times; only the row with the newest date is flagged Keep.

Functions used (tap for the full reference guide):

The example

One customer ID (C-104) was re-exported three times with updated info each time; two others appear once.

ABCD
1Customer IDUpdatedEmailStatus
2C-1041/5/2026[email protected]Superseded
3C-2012/2/2026[email protected]Keep
4C-1043/18/2026[email protected]Superseded
5C-1046/9/2026[email protected]Keep
6C-3304/4/2026[email protected]Keep

The formula

MAXIFS finds the latest date for the current row's key; the IF compares this row's date against it:

=IF(B2=MAXIFS($B$2:$B$6,$A$2:$A$6,A2),"Keep","Superseded") // this row's date compared to the max date for this same ID

How it works

MAXIFS filters by key, then IF compares:

  1. MAXIFS($B$2:$B$6,$A$2:$A$6,A2) looks across the whole date range, restricts to rows where the ID column matches this row's ID, and returns the latest date among just those matches.
  2. B2= compares this row's own date to that latest date. If they match, this row IS the most recent record for its ID.
  3. The absolute references ($B$2:$B$6, $A$2:$A$6) keep the range fixed when the formula is filled down; only A2 and B2 change per row.
  4. Filter or sort on the result column to keep only "Keep" rows for a clean, deduplicated export.

If two records for the same key share the exact same latest date, both will show Keep — add a tiebreaker column (a row number or timestamp) if that is possible in your data and needs to resolve to exactly one row.

Try it: interactive demo

Interactive

This row's date and the latest date on record for the same key:

Variations

Keep the FIRST occurrence instead (oldest wins)

Swap MAXIFS for MINIFS to flag the earliest record per key as the one to keep, useful when the first entry is the authoritative source and later rows are just re-confirmations.

=IF(B2=MINIFS($B$2:$B$6,$A$2:$A$6,A2),"Keep","Superseded")

Count how many superseded rows exist per key

A quick COUNTIFS shows how many times each key was re-exported, useful for spotting an ID with an unusually high update frequency that might indicate a data-entry problem.

=COUNTIFS($A$2:$A$6,A2)-1

Pitfalls & errors

MAXIFS ignores blank date cells but not text-formatted dates — a date typed or imported as text will not compare correctly against real date values and can cause every row for that key to show Superseded, or none to show Keep.

The absolute references in the ranges must cover every row of data, including rows added later. A range typed as $B$2:$B$6 will silently ignore row 7 if new data is appended below it without extending the formula's range.

Add a helper column that counts occurrences of the ID (COUNTIF) before filtering — a customer with only one record will always show Keep regardless of this formula, and separating "was ever duplicated" from "is the current version" is often useful information on its own.

Practice workbook

📊
Download the free Data Cleaning: Keep Only The Most Recent Duplicate Record practice workbook
Edit the yellow date cells; the Keep/Superseded status recalculates per customer ID.

Frequently asked questions

Does this actually delete the superseded rows?
No — it only flags them. Filter the Status column to "Superseded" and delete or archive those rows once you have confirmed the flagging looks right, rather than building deletion into the formula itself.
What if the key spans two columns, like first name plus last name?
Concatenate them into one helper column first (or use MAXIFS with two criteria pairs, one for each key column) — MAXIFS supports multiple criteria ranges in the same formula.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Flag or Keep the First Duplicate · Audit Duplicate Keys · Standardize Phone Number Format

Function references: MAXIFSIF