How to compare two payroll periods in Excel, and a faster way
11 min read
Two payroll exports, two months, a few hundred rows each. The question is simple: what changed, and is any of it a mistake. Excel can answer it, and the method below is the one that survives contact with a real register — the awkward parts are matching employees who are not in both files, and comparing every pay component rather than just the net.
It takes about twenty minutes the first time. At the end there is a note on the four mistakes that make the whole comparison wrong, which matter more than the formulas.
Before you start: get both files into the same shape
Export both periods from your payroll system as Excel or CSV. You need, at minimum, an employee identifier, gross pay and net pay. If the export also gives you the pay components — base, allowances, overtime, bonus, each deduction — take them, because that is where the explanation of any change lives.
Then, in one workbook:
- Put the earlier period on a sheet called
Previousand the later one onCurrent, with the header row on row 1 in both. - Check the two sheets have the same columns in the same order. Payroll exports change between runs more often than you would expect — a new allowance appears, a column is renamed. If they differ, line them up now rather than discovering it in the numbers.
- Make sure the employee identifier is text, not a number. An ID like
007becomes7the moment Excel decides it is numeric, and then it matches nothing. Select the column, then Data → Text to Columns → Finish, with the column format set to Text.
One more thing worth doing before any formula: check each file against itself. Does the sum of the pay components equal the gross column? Does gross minus the deductions equal the net column? If not, the file is already inconsistent and comparing it to another file will produce differences that are nothing to do with the month.
Step 1: build one list of every employee in either period
This is the step most people skip, and it is why their comparison misses the two most expensive errors — someone who left and was paid anyway, and someone who joined and was not.
Copy the employee ID column from Previous into a new sheet called Compare, in column A under a header. Then paste the ID column from Current directly beneath it. Select column A, then Data → Remove Duplicates.
You now have every person who was paid in either month, exactly once. The row count is itself informative: if it is larger than either period, the roster moved.
Step 2: pull both periods’ figures against that list
With the IDs in column A from row 2 down, put the previous and current net pay side by side. If your Excel has XLOOKUP:
B2: =XLOOKUP($A2, Previous!$A:$A, Previous!$D:$D, "not in period")
C2: =XLOOKUP($A2, Current!$A:$A, Current!$D:$D, "not in period")Replace $D:$D with whichever column holds net pay on each sheet. On an older Excel without XLOOKUP, the equivalent is:
B2: =IFERROR(VLOOKUP($A2, Previous!$A:$Z, 4, FALSE), "not in period")where 4 is the position of the net pay column counting from the ID column. The literal text "not in period" matters: it is doing real work. If you return 0 instead, a joiner looks like somebody whose pay fell to zero, and a leaver looks the same. Those are different events and you want to see which is which.
Step 3: the difference, and the percentage
Put the change in column D and the percentage in column E. Both have to cope with the text in B and C:
D2: =IF(OR(NOT(ISNUMBER($B2)), NOT(ISNUMBER($C2))), "", $C2-$B2)
E2: =IF(OR(NOT(ISNUMBER($B2)), NOT(ISNUMBER($C2)), $B2=0), "", ($C2-$B2)/$B2)Format column E as a percentage. The $B2=0 guard stops the division error on anybody whose previous net was zero — unpaid leave for a whole period, usually.
Now sort column D largest to smallest and read the top and the bottom. Those are the rows worth a human looking at. Sorting by the percentage instead will put a 3.00 change on a small figure above a 4,000 change on a large one, which is rarely what you want first.
Step 4: do the same per pay component, because net hides things
A net pay that did not move is not evidence that nothing happened. An overtime payment that stopped and an allowance that started, at the same amount, net to nothing. The register looks unchanged and two things changed.
So repeat columns B to D for each component you exported. Rather than copying the formula by hand per column, put the component column letters across row 1 and use a two-dimensional lookup. If the headers on Current match the headers you have typed:
=XLOOKUP($A2, Current!$A:$A, INDEX(Current!$A:$Z, 0, MATCH(F$1, Current!$1:$1, 0)), "")That reads: find this employee, and give me the column whose header matches the one at the top of this column. Fill it right across every component, then build the matching block for Previous and subtract one from the other.
You now have a grid of every employee against every component, showing what moved. This is the comparison a payroll check actually needs.
Step 5: flag the rows that need a reason
Add a column that says why a row is worth attention, so the list sorts itself rather than asking you to re-read it:
=IFS(
NOT(ISNUMBER($B2)), "New this period",
NOT(ISNUMBER($C2)), "Not paid this period",
$C2<0, "Negative net",
ABS($E2)>=0.2, "Net moved 20% or more",
TRUE, ""
)Twenty per cent is a starting point, not a rule — set it where your own payroll normally sits. A register with commission on it moves far more than one without, and a threshold that flags half the rows is the same as no threshold at all.
The four mistakes that make this comparison wrong
These matter more than the formulas, because each one produces a comparison that looks finished and is not.
Matching on name instead of employee ID
Names change — marriage, a corrected spelling, a middle initial that appears in one export and not the other. Two people genuinely share a name more often than people expect. Match on the identifier your payroll system assigns, always, and if the export does not include one, fix the export rather than working around it.
Treating a missing employee as a zero
Covered above, and worth repeating because it is the default behaviour of every lookup formula written without a fallback. A joiner and a leaver are the two changes most likely to cost real money — someone paid after their last day, someone paid a full period for a fortnight’s work — and both are invisible if the formula quietly returns zero.
Comparing the wrong file version
If a correction was made after the export, you are comparing a register that no longer exists. Check the export timestamp against the last change in the payroll system before you start. This survives every other check on the list, because the arithmetic is all perfectly correct — just about the wrong file.
Duplicated employee rows
If one person appears twice in an export, a lookup returns the first row and silently ignores the second. Someone paid twice then reads as unchanged. Before comparing, count the IDs on each sheet: =ROWS(A2:A500) against =SUMPRODUCT(1/COUNTIF(A2:A500,A2:A500)). If the two numbers differ, there are duplicates to resolve first.
When the spreadsheet stops being the right tool
The method above works. It is also rebuilt from scratch every period, and that is the actual problem rather than the formulas: the comparison is only as reliable as the half hour somebody had to spend on it this month. The failure mode is not a wrong formula, it is a month where nobody had the half hour.
If your register has a stable set of columns and you run this every period, the work is worth automating — either with a saved workbook and a macro, or with something that reads the export directly and keeps the column mapping between runs.
Whichever way you do the comparison, it answers only half the question. A separate piece covers what to check before you approve a payroll run — including the two sums that tell you whether the register adds up at all, which a comparison between periods cannot see.