Additive fact
A measure that gives a correct result when summed across any dimension of its fact table, such as quantity sold. Semi-additive facts, such as balances, can be summed across some dimensions and not others, and non-additive facts, such as ratios, cannot be summed at all.
Also: additive facts · fully additive fact · additivity
On this page · 7 sections
- Category
- Data modeling
- Also known as
- additive facts, fully additive fact, additivity
- Goes deeper in
- Data Modeling
An additive fact is a number that stays meaningful however it is added up. Sales amount can be summed by product, by store, by customer, and by day, and each total is a real figure. Ralph Kimball sorts the numeric measures in a fact table into three categories by this property, and treats fully additive facts as the ones to aim for.
A semi-additive fact can be summed across some dimensions and not others. Balances are the standard case: account balances add up across accounts and branches on a single day, while adding one account's balance across thirty days produces a number nobody holds. Inventory levels and headcount behave the same way. Across time they are averaged, or read at the end of the period.
A non-additive fact cannot be summed across any dimension. Ratios, percentages, and unit prices are the usual ones. The reliable approach is to store the additive parts, such as revenue and cost, add those up to the level the report needs, and only then divide. The ratio is computed last, in the query or the BI tool.
-- Semi-additive: a balance adds across accounts, not across days.
with daily as (
select date_key, sum(balance) as total_balance
from fct_daily_balances
group by date_key
)
select
sum(total_balance) as summed_across_days,
avg(total_balance) as average_daily_balance
from daily;
-- Non-additive: add up the parts first, then divide.
select
round(avg(1.0 * (revenue - cost) / revenue), 4) as average_of_line_margins,
round(1.0 * sum(revenue - cost) / sum(revenue), 4) as margin
from fct_order_lines;A BI tool will sum any numeric column it is given. Whether the result is right depends on the fact's additivity, which the column name seldom reveals. Recording it in the model documentation or the metric definition prevents the wrong default.
It is also a design test. If a measure cannot be made additive at the chosen grain, ask whether its components can be stored. A fact table of additive components can rebuild any ratio; a fact table of ratios cannot rebuild the components.
- Summing a balance, inventory level, or headcount over a date range. The result grows with the number of days and describes nothing.
- Averaging a stored percentage. The mean of row-level margins weights a small order the same as a large one and differs from total margin over total revenue.
- Storing unit price as the only money column. Price times quantity, the extended amount, is the additive fact; price alone cannot be rolled up.
- What is an example of a semi-additive fact?
- An account balance. On any one day, balances can be added across accounts, customers, and branches to give a total on deposit. Across days they cannot: adding Monday's balance to Tuesday's counts the same money twice. Inventory on hand, open support tickets, and number of employees are semi-additive for the same reason.
- How do you aggregate a semi-additive fact over time?
- Pick the aggregation that matches the question. For the level at the end of a period, take the value from the last date in the period. For a typical level, sum across the other dimensions within each date first and then average those daily totals. An AVG over all rows gives the average per account per day, which is a different number.
- Is a ratio a fact?
- It can be reported as one and should not be stored as the only one. A ratio is non-additive, so a stored margin percentage cannot be rolled up to a month or a region. Store its numerator and denominator as additive facts, sum each to the level of the report, and divide at the end.
