Sub topic 1
Fact and dimension tables: the shape relationships serve
Prerequisites
This chapter assumes you can do the following:
- Use Power BI Desktop and load data into tables.
- Read tables, rows, and columns.
- Explain what a report visual and a slicer do.
- Describe a measure such as the sum of a column.
Why table shape matters
A relationship tells Power BI how a filter on one table should affect another table. Relationships work best when the tables follow a predictable pattern. That pattern is the star schema, and the rest of this tutorial builds on it.
Fact tables
A fact table records events or measurements. Each row is one thing that happened, such as a sale, a shipment, or a website visit. Fact tables have these traits:
- They are long, often thousands or millions of rows.
- They hold numeric columns you aggregate, such as
SalesAmountorQuantity. - They hold key columns that point to dimension tables, such as
CustomerKeyorProductKey.
Dimension tables
A dimension table describes the things an event involves: who, what, where, and when. Dimension tables have these traits:
- Each row is one distinct item, such as one customer or one product.
- They have a key column with a unique value in every row.
- They hold descriptive text and attributes you group or filter by, such as
Category,Country, orMonth.
The star shape
In a star schema, one fact table sits in the center. Dimension tables surround it and each connects directly to the fact table. Dimensions do not connect to each other.
Each line reads as "one dimension row relates to many fact rows". One customer can appear in many sales, but each sale belongs to one customer. This is the one-to-many pattern, and the next chapters cover it in detail.
How the shape serves relationships
The star shape makes filters easy to predict.
- You pick a value in a dimension, for example
Category = Bikesin a slicer. - Power BI keeps only the dimension rows that match.
- The relationship passes that choice to the fact table, which keeps only the sales rows whose key matches.
- Your measure, such as
SUM ( Sales[SalesAmount] ), adds up only those rows.
Filters flow from the dimension (the "one" side) to the fact (the "many" side). A report visual that groups by a dimension column and sums a fact column works because of this flow.
| Table type | Typical content | Key column | Used for |
|---|---|---|---|
| Fact | Events and numbers | Repeats across rows | Aggregating |
| Dimension | Descriptions of things | Unique per row | Grouping and filtering |
Common mistakes
- One wide table. Loading everything into a single flat table repeats text on every row. It also makes shared dimensions, such as one Date table, hard to reuse.
- Chaining dimensions. Connecting dimensions to each other makes filter paths longer and harder to follow.
- Treating a lookup as a fact. If a table has unique keys and descriptive columns, it is a dimension, even when it has a few numbers.
Exercise
A table has one row per product, a unique ProductKey, and columns for Name, Color, and Category. Is it a fact or a dimension table, and which direction does a filter normally flow between it and the Sales table?
Show answer
It is a dimension table, because each row describes one item and the key is unique. A filter normally flows from the dimension (the one side) to the Sales fact table (the many side).