Sub topic 5
Building the Calculations Layer
This chapter covers the middle layer of a financial model, where assumptions become results. It assumes you can write spreadsheet formulas with relative and absolute references. It also assumes you know the basic income statement and have met the idea of a separate inputs layer. The outputs layer, layout, and checks get their own chapters, so they appear here only where they touch the calculations.
What the calculations layer is
The calculations layer holds all the logic that turns inputs into numbers. Revenue builds, cost schedules, tax, debt balances, and the three financial statements all belong here. It has two rules:
- It reads from the inputs layer and from earlier calculations.
- It contains no assumptions of its own.
The second rule is the one people break. If a formula contains *0.6 or +150000, an assumption is hiding in the logic. Nobody reviewing the inputs sheet will see it, and a scenario switch will not change it.
The Python example below shows the structure. The calculate function takes the inputs dictionary as its only source of numbers.
# INPUTS: every assumption lives in one place, with units in the name.
inputs = {
"revenue_year1": 1_000_000, # currency units
"growth_rate": 0.10, # fraction per year
"cogs_pct": 0.60, # fraction of revenue
"opex": 150_000, # currency units per year
"tax_rate": 0.25, # fraction of positive EBIT
"years": 3,
}
# CALCULATIONS: pure logic, reads only from inputs, holds no constants of its own.
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,
"ebit": ebit,
"net_income": ebit - tax,
})
return rows
# OUTPUTS: presents calculation results, adds no new logic.
def report(rows):
for r in rows:
print(f"Year {r['year']}: revenue={r['revenue']:,.0f} EBIT={r['ebit']:,.0f} net income={r['net_income']:,.0f}")
report(calculate(inputs))Running it prints three lines. Year 1 shows revenue of 1,000,000, EBIT of 250,000 and net income of 187,500. Year 3 shows revenue of 1,210,000, EBIT of 334,000 and net income of 250,500.
The function has no literals except the 1 in 1 + growth and 1 - cogs_pct. Those are part of the arithmetic of growth and percentages, not assumptions. The constant 0 in max(ebit, 0) is also a rule, not a number someone might want to change.
How data moves through the layer
Calculations are a chain of steps. Each step depends on earlier ones, and the chain should only run forward.
Each arrow is a reference in a formula. Inputs can feed any step, but no step refers back to a later one. A formula that refers to something further down the chain is the usual sign of a circular reference. It also makes the model hard to read, because you can no longer follow it in order.
Referencing inputs in a spreadsheet
In a spreadsheet, every calculation cell points to an input cell instead of typing the number. Use absolute references ($C$5) for inputs that apply to every period. That way one formula can be copied across the whole time axis.
Inputs!C5 = 0.10 (growth rate, blue input cell)
Calc!E10 = D10*(1+Inputs!$C$5) (revenue, same formula copied across every year column)
Calc!E12 = E10*(1-Inputs!$C$6) (gross profit, where Inputs!C6 is the COGS percentage)Notice what E10 and D10 do. They are relative references, so when the formula is copied one column right they move to F10 and E10. The input reference stays pinned. This mix of relative references to the same sheet and absolute references to inputs is the core pattern of a calculations sheet.
Rules for writing calculation formulas
One formula per row
Across the time axis, every cell in a row should hold the same formula. If you can select a row and the formula in the first cell differs from the second, one of them is special-cased. Special cases are where errors hide.
The first period often does differ, because there is no prior period to grow from. There are two clean ways to handle it:
- Put the opening value in its own column, and let every forecast column use the same formula.
- Use a flag row, for example
1in the first period and0otherwise, and write one formula that tests it.
The Python if year > 1 plays the same role as the flag. The next chapter in the plan covers the time axis in more detail.
Keep each formula short
A formula that nests five functions is hard to audit. Break it into rows, each with a label. Instead of one cell computing tax after loss offsets, add rows for taxable income, losses used, and tax payable. Rows are cheap, and a reviewer can read each one at a glance.
Label units and signs
Every row gets a label, a unit and a consistent sign convention. Pick one for costs: either show them as positive numbers that you subtract, or as negative numbers that you add. Mixing the two in one model causes sign errors that checks may not catch.
Separate flows from balances
A flow is an amount over a period, such as revenue or depreciation. A balance is an amount at a point in time, such as cash or debt. Keep them in separate rows. Each balance should follow the same shape:
closing = opening + additions - reductions
Then the next period's opening balance equals the prior period's closing balance. Writing balances this way makes roll-forwards easy to check.
What belongs in calculations, and what does not
| Item | Where it belongs | Reason |
|---|---|---|
| Growth rate of 10% | Inputs | It is an assumption someone may change |
| Revenue = prior revenue × (1 + growth) | Calculations | It is logic that uses an input |
| Tax rate of 25% | Inputs | It is an assumption with a source |
| Tax = max(EBIT, 0) × rate | Calculations | It is a rule applied to an input |
| A chart title or summary table | Outputs | It presents results, with no new logic |
| `*0.6` typed inside a formula | Nowhere | It is a hardcode and should move to inputs |
Use this table as a test. For any cell, ask whether a person might want to change it without understanding the formulas. If yes, it is an input.
Handling edge cases
Real models hit situations the simple example avoids.
- Negative values. The tax line uses
max(ebit, 0)so a loss does not create a tax refund. That is a simplification. Many tax systems carry losses forward, which needs a loss balance row built as a roll-forward. - Division by zero. A margin row dividing by revenue fails if revenue is zero. Handle it deliberately, for example
IF(revenue=0, 0, profit/revenue), and do not wrap every formula in a blanket error trap. A blanket trap hides real problems. - Timing. Monthly inputs feeding annual calculations need explicit conversion. Put the conversion factor in inputs, labeled, and not inside the formula.
- Circularity. Interest on an average debt balance depends on the closing balance, which depends on cash flow, which depends on interest. Avoid it by using opening balances for interest, or add an explicit switch if you must break the loop.
Testing the layer
A calculations layer is correct when changing an input changes the right results and nothing else. Try three tests:
- Change one input by 10% and confirm only the expected rows move.
- Set an input to zero or an extreme value and confirm no errors appear.
- Add a check that components sum to totals, as in the following formula.
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)The check returns 0 when the parts match the total within a small tolerance and 1 otherwise. The master check adds them up, and the outputs sheet shows the result. The tolerance is there because floating-point arithmetic rarely gives exact equality. The integrity checks chapter covers this in depth.
Summary of practice
- Calculations read inputs and earlier calculations. They never contain assumptions.
- Use absolute references for inputs and relative references for the time axis.
- Keep one formula per row, short formulas, and consistent signs.
- Build balances as opening plus additions minus reductions.
- Test by changing inputs and by adding checks.
Exercise
A colleague's revenue formula in cell E10 is =D10*1.08+25000. Name the two problems from this chapter's point of view, and rewrite the formula using input cells Inputs!$C$5 (growth rate) and Inputs!$C$7 (annual new-contract revenue).
Show answer
Both 1.08 (a growth assumption) and 25000 (a revenue assumption) are hardcodes inside the logic, so they are invisible on the inputs sheet and a scenario switch cannot change them. Move them to input cells, then write =D10*(1+Inputs!$C$5)+Inputs!$C$7. The input references are absolute, so the formula can be copied across every year column unchanged.
Exercise
A debt balance row has =D30-E31 in the first forecast column but =E30-F31+500 in the second. List what is wrong and how to fix it.
Show answer
The formulas are inconsistent across the row, and the second contains a hardcoded 500. Make the row one formula, closing = opening + additions - reductions, copied across all columns. If 500 is a real new borrowing, put it in an additions row fed from the inputs layer.