Defining data grain for accurate reporting: One row records one order line, product, location and date.; Summing daily balances across dates creates incorrect totals.; Measures must match the grain of their fact table to avoid double counting.
Image: Business Insight Stack

Data Modelling

Part of BI data modelling

Defining facts, dimensions and reporting grain

Define what each BI table row represents, identify valid keys and distinguish additive amounts from balances and ratios before building reports.

Define the grain of each fact table by finishing this sentence: “One row records one ___.” Then identify what distinguishes those rows.

Facts record events or observations; dimensions describe the things used to group and filter them. These choices determine whether a measure can be joined and summed without changing its meaning.

State the grain before joining tables

An order header, an order line and a daily stock observation are different grains. Repeated order IDs in an order-line table may be expected because an order can have several lines. Repeated combinations of order ID and line number need investigation if that combination is intended to identify each line.

Keep the detail the question needs and the source can support. An order-line fact can be grouped by order or month. A monthly product total cannot recover individual order lines that were never retained. State whether cancelled, returned or amended records are included and which date sets the reporting period.

Candidate tableIllustrative row statementMeasure question
Order linesOne row per order and line identifierCan quantity and line amount be summed for the selected population?
Daily stockOne row per product, location and observation dateIs the report showing a balance on a date rather than adding balances across dates?
Monthly targetsOne row per product and target monthIs a daily target defined, or would it require an allocation rule?

These are example designs. Check the actual source keys and business rules before adopting them.

Set the dimension grain

A product dimension might describe product name and category; a customer dimension might describe account segment. A key on the dimension side of an intended one-to-many relationship must identify one row at the chosen dimension grain. If one fact row matches several dimension rows, a join can multiply its measure.

A dimension is not necessarily one row per real-world entity for all time. Retaining historical customer segments can create several dated rows for one customer. Each version needs a distinct row key, and the fact must reference the version selected by the approved history rule. If only current values are needed, a current-value dimension may be simpler.

Classify measures before exposing them

Ask which groupings permit addition. Line quantity can usually be summed across distinct order lines for an agreed population. A daily balance represents a point in time; adding Monday's and Tuesday's balances does not produce a two-day balance. A percentage generally needs to be recalculated from its underlying counts or amounts at the requested grouping, according to its approved definition.

Keep a value at the grain where it is valid. Copying an order-level amount onto every order line makes a sum over the joined lines count some orders repeatedly. Use a line-level amount, calculate the order result once per order, or define a measure that respects the order grain. Summing distinct amount values is not a general repair: separate orders can have the same amount.

Check one reporting slice

For a closed period, compare row counts, distinct business keys and an approved total before and after joining tables. Then group by a dimension, inspect unmatched keys and examine unexpectedly repeated rows. Record the source extract time, filters and date field so the comparison can be reproduced.

The deliverable is a grain statement for each table, an explicit way to identify its rows, and a measure rule a report creator can explain. This table-design task is separate from investigating duplicate source entities or teaching report authors how to spot double counting.

More from Data Modelling

Data Modelling

BI data modelling

Define reporting grain, facts, dimensions, dates, measures and changing attributes in a BI model that produces explainable figures.