Sub topic 2
Putting It Together: The Star Schema
Assume you know basic Power BI Desktop, Power Query, simple DAX, and primary and foreign keys. A star schema organizes a model around a central fact table connected to descriptive dimension tables.
Putting It Together: The Star Schema
A fact table stores events at a defined grain, such as one row per order line. It contains keys and measurements, such as quantity and sales amount. A dimension table stores descriptive fields used for grouping and filtering, such as product category, customer region, or calendar year.
The fact table is the center of the star. Dimensions form the points around it.
Creating One-to-Many Relationships
Each dimension should have one row for each key. The fact table can contain that key many times because many events may involve the same product or date.
For example, DimProduct[ProductKey] is on the one side, and FactSales[ProductKey] is on the many side. In Power BI, create a one-to-many relationship with single filter direction from the dimension to the fact.
| Side | Example | Rule |
|---|---|---|
| One | `DimProduct[ProductKey]` | Values are unique |
| Many | `FactSales[ProductKey]` | Values can repeat |
How Filters Flow from Dimensions to Facts
When a report user selects Category = Bikes, Power BI filters DimProduct. The relationship propagates that filter to matching rows in FactSales. Visuals then aggregate only those rows.
Keep filter direction single by default. Bidirectional relationships can create ambiguous paths and unexpected totals, especially when several dimensions connect to the same facts.
Writing Measures Against the Star
Measures aggregate fact columns while dimensions provide context. The same measure can show total sales, sales by category, or sales by year without changing its definition.
Total Sales =
SUM ( FactSales[SalesAmount] )
Total Quantity =
SUM ( FactSales[Quantity] )When a visual uses DimProduct[Category], Power BI evaluates [Total Sales] separately for each category because the dimension filter reaches the fact table.
Exercise
Which side of a product relationship should contain unique ProductKey values?
Show answer
The dimension side, such as DimProduct[ProductKey], should contain unique values. The fact side may repeat them.