Sub topic 12
Building integrity checks into the model
Auditing tools find problems when a person runs them. Integrity checks find problems every time the model recalculates. This chapter covers how to build checks for the balance sheet, cash, errors, and hardcodes, and how to combine them into one status flag.
This chapter assumes you can write formulas with absolute and relative references, use named ranges, and read a three-statement model (income statement, balance sheet, cash flow). It also assumes you know the common error values from earlier chapters.
What an integrity check is
An integrity check is a formula whose result should always be a known value, usually 0 or TRUE. If the model is internally consistent, the check stays quiet. If an edit breaks something, the check changes.
Good checks share four traits:
- They test a relationship that must hold in every period, not a figure you expect to see in one scenario.
- They return a number or a clear flag, not a message that someone must interpret.
- They sit in a dedicated place, so you can review all of them together.
- They roll up into one master cell visible from the top of the model.
A check that is wrong is worse than no check, because it gives false comfort. Test each check by deliberately breaking the model, as shown near the end of this chapter.
Where checks belong
Keep the detailed checks close to what they test, then link them to a single summary area. A common layout puts a Checks sheet at the front of the workbook. It lists each check by name, shows its result per period, and ends with the master flag.
The balance sheet check
The most important check confirms that assets equal liabilities plus equity in every period. In this example the named ranges Total_Assets, Total_Liabilities, and Total_Equity each refer to the totals row for a period.
=ROUND(Total_Assets - (Total_Liabilities + Total_Equity), 2)The formula returns 0 when the sheet balances. The ROUND function matters because Excel stores numbers in binary floating point. A difference of 0.0000000001 is rounding noise, not a modeling error, but without ROUND it would make the check look broken. Rounding to 2 decimals is a reasonable default when the model is in currency units. If the model is in thousands or millions, rounding to 2 decimals is still tight enough to catch real errors.
Copy the check across every forecast column. Do not check only the final year, because errors can offset each other in a later period and hide an earlier failure.
Common mistakes with balance checks
- Plugging the balance. Some models force the balance sheet to balance by making cash or another line equal to the difference. This hides the very problem the check should reveal. Cash should come from the cash flow statement, not from a plug.
- Using a tolerance that is too loose. A check that accepts any difference under 1,000 will pass errors that matter.
- Checking a sum that is itself wrong. If
Total_Assetsomits a row, the check can still pass. Pair the balance check with a review of the totals formulas.
The cash check
The balance check does not prove the cash flow statement is correct. A separate check compares the closing cash on the cash flow statement with the cash line on the balance sheet.
=ROUND(CF_Closing_Cash - BS_Cash, 2)Here CF_Closing_Cash and BS_Cash are named ranges for the closing cash row and the balance sheet cash row. If the balance sheet pulls cash from the cash flow statement, this check will pass by construction. It is still worth having, because someone may later overwrite the link with a different reference or a typed number.
Other relationship checks follow the same pattern. Examples include opening balance equals prior closing balance, debt schedule ending balance equals the balance sheet debt line, and sum of segment revenue equals total revenue. Write one check for each relationship the model depends on.
The error count check
A single error value can spread through a model and turn hundreds of cells into errors. Rather than scanning the sheets, count them.
=SUMPRODUCT(--ISERROR(C5:N80))ISERROR tests each cell in the range and returns TRUE or FALSE. The double minus converts those values to 1 and 0, and SUMPRODUCT adds them up. A result of 0 means no cell in the range contains an error. Any other number is the count of cells with errors.
Run this check once per sheet over the full used range, and reference each sheet's result from the Checks sheet. Keep these points in mind:
- The check must not include its own cell in the range, or it creates a circular reference.
ISERRORcounts #N/A as an error. If you useNA()on purpose, as described below, expect the count to be nonzero until the cause is fixed. That is the intended behavior.- The range must cover every area where data can be added. If you insert rows or columns inside the range, it grows with them. If you add them outside it, they are not checked.
Make errors visible, not hidden
Wrapping a formula in IFERROR(..., 0) removes the error and also removes the warning. A division by zero then becomes a quiet zero that flows into other calculations. Prefer a pattern that keeps the problem visible:
=IF(C12=0, NA(), D12/C12)When the denominator is zero, this returns #N/A instead of #DIV/0!. The error still shows, and the error count check still catches it. #N/A also makes it clear that the issue is a missing or invalid input, and Trace Error can follow it back to the source. Use IFERROR only where a blank or zero is the correct business result, and document why.
The hardcode check
Row-level consistency is another property you can test. If a forecast row should be entirely formulas, any typed number in it is a possible override. This formula counts non-formula cells in the row.
=SUMPRODUCT(--NOT(ISFORMULA(D20:N20)))ISFORMULA returns TRUE for cells that contain a formula. NOT flips that, so the formula counts the cells that do not. A result above 0 flags a hardcode.
Use this check only on rows where every cell is meant to be a formula. Input rows, such as an assumptions block, are supposed to contain constants, so applying it there produces false alarms. Also, a formula such as =500 or =100*1.05 still passes ISFORMULA, so this check finds typed-over cells but not hardcoded numbers inside formulas. Use Go To Special and Show Formulas, covered earlier, for those.
When a check flags a row, FORMULATEXT helps you compare it with its neighbors:
=FORMULATEXT(E20)Place this in an adjacent cell and copy it across. If one cell shows a different formula pattern from the rest, you have found the inconsistency. FORMULATEXT returns #N/A for a cell with no formula, which is itself a sign of a hardcode.
Combining checks into a master flag
Individual checks are useful only if someone sees them. A master check collapses them into one status.
=IF(AND(Check_Balance=0, Check_Cash=0, Check_Errors=0), "OK", "CHECK MODEL")Here each named cell holds the total of its check across all periods. For the balance and cash checks, summing the raw differences can let a positive error cancel a negative one. Use SUMPRODUCT(ABS(range)) for the sum, so that opposite errors cannot offset.
=SUMPRODUCT(ABS(Balance_Check_Row))Place the master cell where it cannot be missed, such as the top of the cover sheet and each output sheet. Add conditional formatting so "OK" shows green and "CHECK MODEL" shows red. Each time an input changes, the flag tells the user at once whether the model is still sound.
Table of the checks in this chapter
| Check | What it proves | Expected result |
|---|---|---|
| Balance | Assets equal liabilities plus equity | 0 in every period |
| Cash | Cash flow closing cash equals balance sheet cash | 0 in every period |
| Error count | No cell holds an error value | 0 per sheet |
| Hardcode | Formula rows contain only formulas | 0 per audited row |
| Master | All checks pass | "OK" |
Test the checks themselves
A check you have never seen fail is unproven. After building each one, break the model on purpose and confirm the flag changes:
- Type a number over one formula in a forecast row. The hardcode check should flag it, and the balance check may fail too.
- Change a link so the balance sheet cash points to the wrong row. The cash check should fail.
- Set a denominator to 0. The error count should become nonzero.
- Confirm the master flag shows "CHECK MODEL" in each case, then undo the change and confirm it returns to "OK".
Record each test in your findings log so a later reviewer knows the checks were exercised.
Limits of integrity checks
- Checks prove consistency, not correctness. A model can balance and still use a wrong growth rate.
- Checks can be removed or overwritten. Protect the Checks sheet, or at least review it first in any audit.
- A master flag that only tests three items cannot report on a fourth. When you add a new relationship, add a new check and extend the master formula.
- Sign conventions matter. If liabilities are stored as negatives in one model, adjust the balance formula to match.
Exercise
A balance check uses =TotalAssets-(TotalLiabilities+Total_Equity) without ROUND and sometimes shows 0.0000000001, which turns the master flag red. Also, the master check sums the raw balance differences across years and shows "OK" even though one year is off by +50 and another by -50. Give the fix for each problem.
Show answer
For the first problem, wrap the difference in ROUND, for example =ROUND(TotalAssets-(TotalLiabilities+TotalEquity),2), so floating-point noise becomes 0. For the second problem, sum absolute values with =SUMPRODUCT(ABS(BalanceCheck_Row)) so that the +50 and -50 cannot cancel each other and the master check shows "CHECK MODEL".
Exercise
You add =SUMPRODUCT(--NOT(ISFORMULA(D20:N20))) to the assumptions block, where growth rates are typed in. It returns 11. Is this a model error? What should you do?
Show answer
No. Assumption rows are meant to hold constants, so the formula counts them as non-formulas. Apply the hardcode check only to calculation rows where every cell should be a formula, and remove it from input rows.