Kay Abraham

Local time in Prague:

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

  1. How Margin rebuild runs, step by step:
  2. Table one to Join
  3. Table two to Join
  4. Table three to Join
  5. Join to Reconcile
  6. Finance's report to Reconcile (a guard)
  7. Reconcile to Join (fed back)
  8. Reconcile to Match
  9. Match to Business plan pool
Made-up item

04 Under the hood

  1. Built from three raw warehouse tables.
  2. Reconciled until it matched Finance's own report to the cent.
  3. The same method then fed a company report on the Business plan pool.
  4. Done October 2.
margin_check.sql Sketch
-- 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.

Back to the machines