Skip to content
Verification

How to check a migrated calculation against the workbook, value by value

Spot checks find the errors you expected. Comparing every value finds the ones you did not.

By the Tavuni team4 min read

Most migrations off a spreadsheet are tested the same way. Someone who knows the process picks ten orders they understand well, runs them through the new system, compares the totals by eye, and signs it off. It feels thorough. It mostly proves that the new system agrees with the old one on the orders nobody was worried about.

Why spot checks fail#

Calculation errors in a migration are rarely spread evenly. They sit in edge cases: the order just over a discount band, the customer with no region set, the line with a quantity of zero, the total that lands exactly on half a cent. The orders people choose for a spot check are, almost by definition, the typical ones.

Even a random sample does poorly. Suppose one value in every two hundred is wrong. A check of ten values misses every one of them with probability (199/200)10, which is about 95%. A check of a hundred still misses them more than 60% of the time. You would need to check several hundred values to be reasonably sure of seeing even one error, and by then you might as well check them all.

Checking every value is not the thorough option. It is the only one that answers the question.

The answer key you already have#

Here is the part that is easy to miss. When Excel saves a workbook, it stores two things for every formula cell: the formula, and the result it last calculated. That stored result was computed by Excel’s own engine, independently of anything you are building. It is an answer key for every calculated value in the file, and you did not have to write it.

So the test is not “do these ten totals look right?”. It is: take only the inputs (the values people typed), blank every calculated field in the new system, let it compute everything itself, and compare each result with the value Excel stored.

Four outcomes, not two#

A comparison that reports only “match” and “mismatch” will eventually lie to you, because some values fit neither. Report four:

OutcomeWhat it meansWhat to do
AgreesEqual, allowing only for the representation noise of binary numbers (a relative difference around 10⁻⁹).Nothing. Count it.
Rounding edgeThe value sits exactly on a rounding midpoint, and the two systems broke the tie differently.Show it to a person: it is a policy question, not a bug. See the rounding article.
DifferentAny other disagreement.List it with the source cell and both values. Never average it away.
Not checkedNo stored result, a formula the new system cannot evaluate, or a value someone typed over a formula.Count it separately. It is not a pass.

The temptation is to fold the last two rows into the first by widening the tolerance until the report is green. Resist it. A pass rate that includes values nobody checked is worse than no pass rate, because people believe it.

The method, step by step#

  1. Inventory the formulas. List every formula cell and separate inputs (typed values) from calculated values. Hidden sheets count.
  2. Map cells to fields. Each calculated cell becomes a field on a record: row 14 of the Orders sheet, column K, is order 1014’s total.
  3. Load inputs only. Put the typed values into the new system and leave every calculated field empty, so nothing can be copied across by accident.
  4. Recompute everything. Let the new system calculate every field from the inputs, in its own dependency order.
  5. Compare every value. Numbers with a tight relative tolerance; text and dates exactly.
  6. Classify and list. Four counts, and a list of every value that is not “agrees”, with the cell it came from and both values side by side.
  7. Run it again after every change. The same comparison is your regression test from now on. A rule edit that moves a total should move it on purpose.

A real run#

This is the result of exactly that method on the example operations workbook Tavuni ships with, northwind-ops.xlsx, computed when this page was built. The workbook has 2,993 formulas. The generated system was given 590 records with every calculated field blanked, and compared value by value with the workbook’s stored results.

OutcomeValues
Checked2,870
Agrees2,869
Rounding edge1
Different0

The one value on a rounding midpoint is reported on its own line, with the cell, rather than counted as agreement. That is the whole point of the method: the report says what was checked, what agreed, and precisely where a person needs to look.

You can run this exact check yourself, in your browser, on the example workbook at /try.

Written by the Tavuni team. Where an example uses Tavuni’s own output, the numbers come from the example workbook at /try and were computed when this page was built. Corrections are welcome: tell us.

All articles

Try the idea on a real workbook.

The live verification reads an example operations workbook in your browser, compiles its rules and checks every value. No account, nothing uploaded.