New Tool Radar

AI for Data & Spreadsheets

How to Compare Two Versions of a Dataset in Excel

Compare an old and a new version of a dataset by key, and list the rows added, removed and changed.

Schematic with three steps: Match the new rows against the old; Find the removed rows the same way; Compare the values of the matched rows.

When a dataset arrives in a new version, the question is what changed: which rows were added, which were removed, and which values changed. Comparing by a key column, such as an ID, gives you three lists instead of a vague sense that the file looks different.

What you need

  • Excel with the old version on one sheet and the new version on another
  • A key column present in both versions, such as an ID
  • A copy of both files

Step 1: Match the new rows against the old by key

In the new version, add a helper column with =COUNTIF(Old!$A$2:$A$130,A2) to count how many times each new key appears in the old version. A count of 0 means the row is new; a count of 1 means it existed before.

Step 2: Find the removed rows the same way

In the old version, add the same COUNTIF against the new version. A count of 0 means the row was removed. List the added and removed keys separately before looking at changed values.

Step 3: Compare the values of the matched rows

For rows present in both versions, bring the old values beside the new ones with XLOOKUP or VLOOKUP on the key, and flag any row where a value differs. Sort the flagged rows by key so the changes can be reviewed one by one.

Worked example: synthetic two versions of a 120-row list

The table below is a synthetic example. It shows the expected result of comparing two dataset versions; no files were opened.

Change Rows Result
Rows in the old version 120 Source
Rows in the new version 125 Source
Rows added 8 New keys
Rows removed 3 Missing keys
Rows changed 4 Values differ

Expected result (UNTESTED). the new version has 125 rows against 120 before: 8 rows added, 3 removed and 4 changed, which accounts for the difference of 5 rows. All 15 changed rows are listed for review. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Compare by key, not by row position; a sorted file would otherwise look entirely changed.
  • A key with a trailing space will not match its clean twin; trim both key columns first.
  • The Inquire add-in in Microsoft 365 Apps for enterprise can compare two workbooks cell by cell.

Sources

See all