Define metric grain: the row-level meaning behind an aggregate
Metric grain is the atomic level at which a fact row records a measurement. State what one row represents, then check whether joins and aggregations preserve that meaning. Daily sales lines and quarterly targets cannot be combined as if they shared the same detail level.
Define one row
Use a sentence such as “one row is one product line on one order, dated by order date,” not a vague “one order.” Grain is determined by the actual dimension-key values, not just by which columns exist. This guide covers fact tables and BI semantic models, based on Microsoft Fabric/Power BI and Google Looker documentation; no live model test is claimed.
For each fact, record the event or state, row unit, keys and time basis, measures and their additivity, and a unique key. A date key containing only each month’s first day means the fact is monthly, even if the key is named Date. Do not repeat a quarterly target on daily or monthly rows as though it were a value at that finer grain unless a defensible allocation rule exists.
Why mixed grain breaks results
Consider a fictional case where the quarterly target fact has one row per product group and quarter, while the sales fact has one row per order line. Amounts use illustrative units, not real results. Assume a target of 400 for Hardware and 350 for Software, with two sales rows for Hardware and one for Software during the quarter.
| Product group | Target once | Sales rows | Actual sales total | Target total after direct join to sales rows |
|---|---|---|---|---|
| Hardware | 400 | 2 | 300 | 800 |
| Software | 350 | 1 | 300 | 350 |
| Total | 750 | 3 | 600 | 1,150 |
The correct target is 400+350=750; actual sales are 600, so the gap is 600−750=−150. Joining targets directly to sales lines repeats the Hardware target twice, producing a joined target total of 1,150 and an apparent gap of −550. Aggregate sales to product-group-quarter before joining to targets, then compare row counts and totals before and after the join to find duplication.
A tool such as Looker may require unique, non-NULL primary keys to aggregate joined measures correctly. Such features do not repair an incorrect grain or join. Looker measure documentation
Choose valid aggregation
Additive measures such as quantity or single-currency revenue can usually be summed across dimensions. Inventory balance is semi-additive: it may sum across products but not across dates; use an end-of-period or defined average. Rates, unit prices, and ratios are often non-additive. Recompute a ratio from aggregated numerator and denominator, not by averaging row-level percentages.
Validation sequence
Write the grain sentence. 2. Test uniqueness and nulls for the declared key. 3. Aggregate each fact separately to a shared grain. 4. Compare row counts and totals before/after joins. 5. Apply an aggregation rule appropriate to the measure. 6. Test daily/monthly/quarterly views and explain any total that should not be additive.
If totals increase after a join, inspect one-to-many keys and duplicate dimension rows. If quarterly targets repeat by month, do not label them monthly without an allocation rule. If a ratio total looks wrong, recompute numerator and denominator under the same filters. If stock totals grow across dates, use a point-in-time rule. Grain makes these checks explicit; it does not automatically prevent errors.
Official references
[Microsoft Fabric: Modeling fact tables](https://learn.microsoft.com/fabric/data-warehouse/dimensional-modeling-fact-tables)
[Power BI: Understand star schema and its importance](https://learn.microsoft.com/power-bi/guidance/star-schema)
[Google Cloud Looker: measure parameter and join primary keys](https://docs.cloud.google.com/looker/docs/reference/param-field-measure)
[Google Cloud Looker glossary: fanout](https://docs.cloud.google.com/looker/docs/glossary?hl=en)