Define fact grain
Start with a business question
Grain describes exactly what a row represents. Before building a visual, ask what event is counted, what period is covered, and what grouping is needed. In sales.csv, one row is one order line, identified by LineID. An order can contain several lines, so OrderID is not unique. A key identifies a record at its declared grain; a lookup key identifies a record in a related table. You cannot infer grain from a column name or assume every repeated value is a duplicate.
Example 1: count orders, not lines
Use the five original clean sales rows from Chapter 03.
| OrderID | LineIDs | Revenue (USD) |
|---|---|---|
| O01 | L01, L02 | 54 |
| O02 | L03 | 36 |
| O03 | L04 | 50 |
| O04 | L05 | 60 |
Five lines represent four orders. Removing one of the O01 lines would erase a legitimate purchase. Total revenue remains 200 USD when the lines are grouped into orders, but the average revenue per line is 40 USD and average revenue per order is 50 USD. Both averages are valid answers to different questions.
Example 2: compare grains before combining
Suppose a separate illustrative North January budget contains one row for the entire month, with a target of 120 USD. The three North sales lines total 104 USD in the supplied January 5–7 extract. Repeating the monthly target on each of the three lines and summing produces 360 USD, which is wrong. The original target stays 120 USD. The observed extract is 104/120, or about 86.7% of the monthly target, not a full-month performance verdict. Compare actual and target at a compatible region-and-month grain, and label the actual as partial period.
Keys and related tables
The clean Products table contains one row per ProductKey. Several Sales lines can use one product. This is a one-to-many relationship from Products to Sales, with the product lookup on the one side. LineID remains the sales record identifier. A duplicate lookup key would make the intended lookup ambiguous. Later modeling chapters will implement relationships; here you only need to identify the two grains and predict the effect of grouping.
Common mistakes and practice
Do not count every row as an order, average averages without their denominators, or compare a whole-month budget to an unlabeled partial-month extract. Define a metric contract for average order revenue: eligible rows, numerator, denominator, currency and covered dates. Then compute the line count, distinct order count and average order revenue for North using the clean fixture. Explain why two lines of O01 must remain.
Official reading
Star schema and granularity · Model relationships. Conceptual examples use original synthetic data; no native model was executed.