Build a sales fact table at a stable grain
Finance receives one order line per product and a separate customer extract with mixed-case keys.
Build a sales fact table at a stable grain
Finance receives one order line per product and a separate customer extract with mixed-case keys. Joining before cleaning can inflate revenue or lose orders. Declare the grain, normalize keys, and count both matches and exceptions before publishing.
At 44:41 the instructor identifies records absent from a lookup with an anti join. Compare that missing-key case with the duplicate-key example below.
Work through the decision
Two invoice lines worth 18 and 22 join to two identical customer entries. Does a sum of 80 validate the load?
Check your reasoning
The source total was 40. Prove the dimension key is unique, correct its survivor rule and repeat the join. Keep unmatched lines visible as exceptions.
Continue in the recording · 41:16 · 42:42.
Decisions and tradeoffs
- Left anti join
- An anti join returns left-side keys that have no matching dimension entry.
- Deduplicate on a normalized business key
- Standardize the key first and choose the surviving record by an explicit ordering rule.
- Denormalize a dimension
- Fold descriptive hierarchy levels into one row per dimension key when attributes share that grain.
- Pre-aggregate at the requested grain
- Group only after choosing the reporting grain and aggregation behavior for each measure.
- Explicit type conversion and quarantine
- Parse keys, dates and amounts using the intended locale and precision. Preserve failed conversions for investigation.
- Reusable SQL view
- A view names a reusable SELECT without storing a separate copy of the returned rows.
- Parameterized SQL function
- A table-valued function can accept inputs and return a relation for another query to compose.
- Stored procedure
- A procedure can coordinate multiple SQL statements and control the sequence of writes.
Practice each guide skill
Use these prompts in the order of the published guide. Microsoft bullet numbers here are local references.
- Choose a view for a named projection, a function for an argument-dependent query and a procedure for staged writes.
- Add net amount from quantity, price and discount. Reconcile against a trusted invoice.
- Use one fact row per order line and unique dimension keys. Test a new customer without sales.
- Flatten product hierarchy attributes to a single product row and test uniqueness.
- Build a daily rollup and reconcile its monthly sum to the line facts.
- Compare an inner join, left join and left anti join on a missing customer.
- Normalize keys before deduplication and separate missing references from genuinely optional values.
- Parse a localized price and reject an invalid date without silently replacing it with zero.
- Remove cancelled lines before grouping and compare the retained count against source statuses.
Official objectives for this lesson
Related lesson · Choose a batch ingestion and transformation path
Build a sales fact table at a stable grain quiz
Answer 3 questions. Check each answer for an explanation.