PostHog Handbook Library / Growth

1,592 words. Estimated reading time: 8 min.

Revenue views

Auto TL;DR

At a Glance

This long page covers these main areas. The list is generated from the article headings, so it updates with every handbook rebuild.

  1. The layers
  2. Where to find what
  3. Customer merges (combining accounts)
  4. Manual overrides
  5. Invoice types and classifications
  6. The revenue waterfall
  7. Known caveats
  8. Changing the views

Our revenue reporting runs on a small chain of warehouse views in the PostHog project. The chain starts from billing's invoice rows and ends in one row per customer per month with revenue by product, usage by product, discounts, credits and refunds. Most revenue dashboards, the comp and quota views, and the sales and customer success account views read from it.

This page explains how the chain is layered, where to find which data, and where the exceptions live. It does not copy the SQL. Each view carries a header comment and column descriptions that describe its logic in detail. When this page and a view disagree, the view is right and this page needs an update.

The views share the prefix iwa. It stands for "invoice with annual", the billing table the chain reads.

The layers

billing_customer ─────────────┬─> iwa_seed_customer_merges      (seed: one customer, several accounts)
                              └─> iwa_seed_manual_overrides     (seed: hand-applied exceptions)

invoice_with_annual + merges ────> iwa_stg_invoice_rows         (staging: one row per invoice row)
billing_usagereport + merges ────> iwa_stg_usage_month          (staging: usage per customer per month)

iwa_stg_invoice_rows + overrides ─> iwa_fct_customer_month      (fact: revenue per customer per month)
iwa_fct_customer_month + usage ───> iwa_summary_customer_month  (summary: revenue + usage + lifecycle)
iwa_summary_customer_month ───────> iwa_summary_customer_month_recalc (comp / quota / NRR view)

Each layer has one job.

| Layer | View | Grain | What it adds | |---|---|---|---| | Seed | iwa_seed_customer_merges | one row per merge | Maps a customer's other billing customer and organization ids to one canonical id, so all of that customer's revenue and usage land on one row per month. | | Seed | iwa_seed_manual_overrides | one row per organization, month range and field | Every hand-applied exception, with a note that says why. | | Staging | iwa_stg_invoice_rows | one row per invoice row | The only reader of the invoice table. Canonical ids, the month, one column per product, the resolved discount rate, Stripe amounts, balance credits. | | Staging | iwa_stg_usage_month | customer x organization x month | The only reader of the usage report table. Usage per product from the last report of each billing period. | | Fact | iwa_fct_customer_month | customer x organization x month | Sums the invoice rows, decides the month's invoice type, applies the summary overrides, and builds the revenue waterfall. | | Summary | iwa_summary_customer_month | customer x organization x month | Fact plus usage, a web analytics estimate, and lifecycle counters. The headline view. | | Recalc | iwa_summary_customer_month_recalc | customer x organization x month | The comp, quota and NRR basis. Restates old straight-line months, applies the recalc overrides, adds product adoption flags. |

Two rules keep the chain honest:

Where to find what

| You want | Read | Notes | |---|---|---| | Revenue by customer and month, by product | iwa_summary_customer_month | total_mrr is billing's own figure, net of credits and refunds. Per-product columns end in _mrr. | | Usage by customer and month, by product | iwa_summary_customer_month | Columns end in _usage. Usage joins on customer, organization and month. A month with no usage report has null usage. | | The number used for comp, quota and NRR | iwa_summary_customer_month_recalc | total_mrr here is the usage basis. It differs from the summary only on pre-2026 annual months. | | A single invoice row, or why a month looks odd | iwa_stg_invoice_rows | Filter on customer_id and month. invoice_type and invoice_classification explain most surprises. | | Which accounts are combined into one customer | iwa_seed_customer_merges | Names are looked up for display. Joins use the ids. | | Which months carry a manual exception, and why | iwa_seed_manual_overrides | Read the note column first. |

The first month of a customer, the number of paying months, and the months since the last payment are in the summary view as first_month, paying_month_number and months_since_last_payment.

Customer merges (combining accounts)

One customer can hold more than one PostHog account. A customer migrates from one account to another, for example from the EU region to the US region or to a new organization under a new contract. A customer can also run two accounts at the same time, for example two teams of one company. In both cases we want one complete view of that customer's revenue and usage. Without a merge, a migration shows as a churn and a new customer in the same month, and two parallel accounts show as two small customers instead of one.

iwa_seed_customer_merges is the single list of these merges. Each row maps one account's billing customer id and organization id to the canonical ids of that customer. Both staging views apply it, so invoices and usage always land on the same canonical id. To add a merge, add one row to the seed. Do not edit any other view for this.

The seed maps ids, not names. Names are looked up live for readability only.

Manual overrides

iwa_seed_manual_overrides holds every hand-applied exception. Each row overrides one field for one organization over an inclusive month range and carries a note that says why.

Two scopes exist:

To add an exception, add one row to the seed with a note. Do not edit view SQL for a one-customer fix.

Invoice types and classifications

Every invoice row has a type and a classification. The fact view turns them into selected_type for the month.

Types:

selected_type is annual when the month has any annual row. Otherwise it is the type of the latest-ending invoice row in the month.

Classifications: standard (pay as you go), annual (a customer on an annual contract, including its usage invoices), and startup (a customer on the startup program). Trials produce no invoice rows and so have no rows in these views. A trial that later pays appears from its first invoice.

Two things follow from this:

The revenue waterfall

Every row in the fact, summary and recalc views reconciles by addition:

total_mrr_before_discount - discount_amount - credit_applied - refund = total_mrr

The identity holds on every row except pre-2026 months where billing reported annual customers straight-line and the month also carried balance credits. is_straight_line_annual marks those months and the _usage_basis columns restate them.

Known caveats

Changing the views

Canonical URL: https://posthog.com/handbook/growth/revops/revenue-views

GitHub source: contents/handbook/growth/revops/revenue-views.md

Content hash: d663a161b1f9746e

Static reader notes
  • MDX_COMPONENT_STATIC_ADAPTER: Adapted interactive MDX components for static reading: PrivateLink.