Additive, semi-additive and non-additive measures
Before you add up a number that is already aggregated, ask across which dimension it adds. Additive measures (sales, quantities, costs) sum across customers, products and days. Semi-additive ones (a balance, a stock, MRR, headcount) sum across accounts but not over time: each month-end value already holds the months before. Non-additive ones (distinct counts, ratios, averages) sum across nothing: recompute them from the detail.
-- MRR of the first quarter: March's, not January + February + March
SELECT SUM(mrr) FROM fct_mrr WHERE month_start = DATE '2025-03-01';
-- monthly active users: from the events, not from 30 daily counts
SELECT COUNT(DISTINCT user_id) FROM events
WHERE occurred_at >= DATE '2026-06-01' AND occurred_at < DATE '2026-07-01';
-- a rate: divide the totals, never average the rates
SELECT SUM(refunded) / SUM(revenue) FROM fct_orders;
The trap. Summing what does not add gives a confident number and no error: twelve month-end balances count January twelve times, and in one month of a product's data, 30 daily active-user counts add up to 37,667 where 16,741 people were active. Keep the grain below the aggregate (user × day) and both parts of each ratio, so that any period can be recomputed.
On your warehouse. Semantic layers write the rule down: in dbt, a non_additive_dimension makes MRR keep the
period's last month, and a distinct count is never rolled up from pre-aggregated rows. Approximate distinct counts are
the exception: HyperLogLog sketches, on Snowflake, BigQuery, Databricks or Redshift, can be merged across days.
WITH events(day, user_id, amount) AS (VALUES
(DATE '2026-06-01', 'ana', 10.00), (DATE '2026-06-01', 'ben', 5.00),
(DATE '2026-06-02', 'ana', 8.00),
(DATE '2026-06-03', 'ana', 4.00), (DATE '2026-06-03', 'cleo', 6.00)),
daily AS (
SELECT day, SUM(amount) AS revenue, COUNT(DISTINCT user_id) AS active_users
FROM events
GROUP BY day)
SELECT (SELECT SUM(revenue) FROM daily) AS revenue_from_days,
(SELECT SUM(amount) FROM events) AS revenue_from_events,
(SELECT SUM(active_users) FROM daily) AS users_from_days,
(SELECT COUNT(DISTINCT user_id) FROM events) AS users_from_events;
| revenue_from_days | revenue_from_events | users_from_days | users_from_events |
|---|---|---|---|
| 33.00 | 33.00 | 5 | 3 |
WITH month_end(month_start, account, balance) AS (VALUES
(DATE '2025-01-01', 'bank', 100), (DATE '2025-01-01', 'till', 20),
(DATE '2025-02-01', 'bank', 120), (DATE '2025-02-01', 'till', 30),
(DATE '2025-03-01', 'bank', 90), (DATE '2025-03-01', 'till', 10))
SELECT SUM(balance) AS summed_over_months,
SUM(CASE WHEN month_start = DATE '2025-03-01' THEN balance END) AS cash_end_of_q1
FROM month_end;
| summed_over_months | cash_end_of_q1 |
|---|---|
| 370 | 100 |