002 Machines 04 / 07
Margin rebuild
Finance's gross margin report, rebuilt from the raw warehouse tables and matched to the cent. Then a company report on the Business plan pool: health, margin, leaks, projection.
- Status
- Done
- Since
- Done October 2026
- Built with
- SQL on Snowflake
01 The miss
The team's numbers didn't match Finance's.
Corrected Margin rebuild K.A.
02 The machine
SQL on Snowflake. Three raw warehouse tables, joined and reconciled until the result matched Finance's gross margin report to the cent. Then a company report on the Business plan pool: health, margin, leaks and projection, on one page.
03 How it runs
- How Margin rebuild runs, step by step:
- Table one to Join
- Table two to Join
- Table three to Join
- Join to Reconcile
- Finance's report to Reconcile (a guard)
- Reconcile to Join (fed back)
- Reconcile to Match
- Match to Business plan pool
04 Under the hood
- Built from three raw warehouse tables.
- Reconciled until it matched Finance's own report to the cent.
- The same method then fed a company report on the Business plan pool.
- Done October 2.
-- rebuild the margin, then check it against Financewith rebuilt as ( select u.month, sum(b.revenue) - sum(c.cost) as gross_margin from usage u join billing b on b.account = u.account join costs c on c.account = u.account group by u.month)select r.month, r.gross_margin - f.gross_margin as differencefrom rebuilt rjoin finance_report f on f.month = r.month;-- done when every row reads 0.00 The method, written for this page. Names are made up and no numbers leave the company.
05 What changed
- One set of numbers for the team and Finance.
- A company report on the Business plan pool: health, margin, leaks, projection.
06 What I can show
This page describes the method. The numbers stay inside the company.