Sub topic 12
Integrity checks
This chapter assumes you can build a three-layer model with a single inputs area, consistent row formulas across the time axis, and an outputs sheet that only summarizes. It also assumes you know basic Excel functions such as SUM, ABS, IF, and AND. Here you will add a layer of tests that tell you whether the model's structure still holds after every change.
Why a model needs checks
A model can produce a number and still be wrong. A pasted value can overwrite a formula. A row can be summed over the wrong range. An input can be changed to a value the logic never expected. None of these errors produce an Excel error message. The model just shows a plausible, incorrect figure.
An integrity check is a formula that tests a relationship that must be true if the model is built correctly. It returns a flag, usually 0 for pass and 1 for fail. Checks do not prove the model is right. They catch the structural breaks that are most common and most expensive to find late.
Checks fit the three-layer design because each layer has its own failure modes:
- Inputs can be missing, out of range, or inconsistent with each other.
- Calculations can fail to reconcile, drift across the time axis, or leave a balance unmatched.
- Outputs can disagree with the calculations they claim to summarize.
What to check
Group checks by the thing they protect.
Reconciliation checks
A reconciliation check confirms that components add up to a total computed another way. Examples:
- Revenue by product sums to total revenue.
- Opening balance plus movements equals closing balance.
- Net income on the income statement equals the net income line that feeds the cash flow.
- The sum of annual figures on the outputs sheet equals the total of the same row on the calculation sheet.
The balance sheet check is the best known: assets minus liabilities minus equity must be zero in every period.
Boundary and sanity checks
These test whether inputs and results fall in a believable range:
- A percentage input lies between 0 and 1.
- The number of years is a positive whole number that does not exceed the number of columns in the time axis.
- Cash does not go negative unless a revolver is available to cover the gap.
- Scenario selector values are one of the allowed options.
Consistency checks
These test the structure itself:
- The timeline flags (start, end, period number) are continuous with no gaps.
- A row that should hold one formula across all columns has not been overwritten. This can be tested by comparing the row total with an independent calculation.
- Switches are set to valid values, and only one scenario is active.
Output-to-calculation checks
The outputs layer must contain no new logic, so every figure there should equal a figure in the calculations layer. A check that compares the two catches a hardcoded number typed into a report.
Writing a single check
The topic's example formula shows the standard pattern:
Checks!C3 = IF(ABS(SUM(Calc!E20:E22)-Calc!E25)<0.01, 0, 1)
Checks!C10 = SUM(Checks!C3:C9)
Outputs!B2 = IF(Checks!C10=0, "All checks pass", "CHECK ERRORS: "&Checks!C10)Three design choices matter here.
- Use a tolerance, not equality. Floating-point arithmetic means two values that should match can differ by a tiny amount, such as 0.0000001. Testing
=0can fail for no real reason.ABS(difference)<0.01accepts rounding noise and still catches real errors. Put the tolerance in the inputs layer as a named value so it is not a hardcode inside every check. - Return 0 for pass and 1 for fail. With this convention you can add checks together. A total of 0 means everything passes. A total above 0 tells you how many checks failed.
- Show the result where people look. The master check on the outputs sheet means no one reads results without seeing the model's status.
Checking across the time axis
Most checks need to hold in every period, not just one. Build the check row on the same time axis as the calculations, one formula per row copied across all columns, then collapse the row to a single flag.
Checks!E5 = ABS(Calc!E30-Calc!E40-Calc!E50) (difference in each period)
Checks!C5 = IF(SUMPRODUCT(ABS(Checks!E5:P5))<0.01,0,1) (one flag for the whole row)Using SUMPRODUCT(ABS(...)) sums absolute differences without needing an array entry in older versions of Excel. This avoids a common mistake: summing signed differences, where a positive error in one year cancels a negative error in another and the flag falsely passes.
A worked example in code
The same idea can be written in Python. The calculation layer from the earlier chapters returns rows. A separate checks function reads those rows and the inputs, and returns a list of failures.
inputs = {
"revenue_year1": 1_000_000,
"growth_rate": 0.10,
"cogs_pct": 0.60,
"opex": 150_000,
"tax_rate": 0.25,
"years": 3,
"tolerance": 0.01,
}
def calculate(inp):
rows = []
revenue = inp["revenue_year1"]
for year in range(1, inp["years"] + 1):
if year > 1:
revenue = revenue * (1 + inp["growth_rate"])
gross_profit = revenue * (1 - inp["cogs_pct"])
ebit = gross_profit - inp["opex"]
tax = max(ebit, 0) * inp["tax_rate"]
rows.append({
"year": year,
"revenue": revenue,
"gross_profit": gross_profit,
"ebit": ebit,
"tax": tax,
"net_income": ebit - tax,
})
return rows
def run_checks(inp, rows):
"""Return a dict of check name -> 0 (pass) or 1 (fail)."""
tol = inp["tolerance"]
checks = {}
# Input boundary checks
checks["rates_between_0_and_1"] = int(
not all(0 <= inp[k] <= 1 for k in ("cogs_pct", "tax_rate"))
)
checks["years_matches_rows"] = int(len(rows) != inp["years"])
# Reconciliation: gross profit - opex - tax = net income in every year
diff = sum(
abs(r["gross_profit"] - inp["opex"] - r["tax"] - r["net_income"])
for r in rows
)
checks["net_income_reconciles"] = int(diff >= tol)
# Independent recalculation of final-year revenue
expected = inp["revenue_year1"] * (1 + inp["growth_rate"]) ** (inp["years"] - 1)
checks["revenue_matches_closed_form"] = int(abs(rows[-1]["revenue"] - expected) >= tol)
return checks
rows = calculate(inputs)
results = run_checks(inputs, rows)
total = sum(results.values())
for name, flag in results.items():
print(f"{name}: {'PASS' if flag == 0 else 'FAIL'}")
print("All checks pass" if total == 0 else f"CHECK ERRORS: {total}")The last check is worth noting. It recomputes final-year revenue with a closed-form formula that does not use the loop. If someone later changes the loop and breaks the growth logic, the two methods disagree. An independent recalculation is one of the strongest kinds of check.
Placement and structure of the checks
Put all checks on one dedicated sheet, in a block with a consistent layout:
| Column | Content |
|---|---|
| A | Check number |
| B | Plain description of what is tested |
| C | Flag (0 or 1) |
| D | Location of the item tested, so a reviewer can jump to it |
Group checks by layer with a subtotal for each, then a master total at the bottom. Link the master total to the outputs sheet and to the top of the inputs sheet, so the status is visible on the page where users change assumptions.
Common errors in checks
- Checks that cannot fail. A check that compares a value with itself, or two cells that are linked, always passes. Test a check by deliberately breaking the model and confirming the flag turns to 1.
- Hardcoded tolerances. A
0.01typed into 40 formulas is exactly the problem the inputs layer exists to prevent. - Signed differences that cancel. Use
ABSbefore summing. - Check flags left out of the master total. When you add a check row, extend the master
SUMrange. Using a range that includes a spare blank row above and below the block helps. - Hiding checks. A hidden check sheet is a check no one reads. Keep it visible and keep the status message on the outputs sheet.
- Treating a pass as proof. Checks catch structural breaks. They cannot confirm that your growth assumption is sensible.
- Too many noisy checks. If checks fail regularly for harmless reasons, users start ignoring them. Keep each check meaningful and fix the cause of any false alarm.
Checks and scenarios
When the model has scenarios, run your checks under each one. A model can pass with the base case active and fail under the downside case, for example when cash goes negative or a rate input leaves its allowed range. Before releasing a model, cycle the scenario selector through every option and confirm the master flag stays at 0, or fails only where you expect it to.
Exercise
A balance sheet check is written as =IF(SUM(E10:P10)=0,0,1), where row 10 holds assets minus liabilities minus equity for each year. The model shows "All checks pass", but year 2 is off by +500 and year 3 is off by -500. Explain why the check passes and rewrite it so it fails, using a tolerance of 0.01.
Show answer
The signed differences cancel: +500 plus -500 sums to 0, and an exact-zero test accepts it. Sum absolute differences instead and compare with a tolerance: =IF(SUMPRODUCT(ABS(E10:P10))<0.01,0,1). The tolerance should be a named input rather than a typed 0.01.
Exercise
Name two checks you would add for the Python model above that test the inputs layer, and say what each returns when the model is built correctly.
Show answer
Example answers: the growth rate must lie in a plausible range (for instance between -1 and 1), and the number of years must be a positive whole number. Each check returns 0 when the condition holds and 1 when it fails, so a correct model returns 0 for both.