Sub topic 1
Starting point: facts and dimensions
Every many-to-many problem in a Power BI model is easier to see against a clean baseline. This chapter sets that baseline: a star schema, the layout that most Power BI models follow, and the sample tables used in the rest of the tutorial.
Prerequisites
This chapter assumes you can:
- Open Model view in Power BI Desktop and read the relationship lines.
- Tell a fact table from a dimension table, at least roughly.
- Understand a one-to-many relationship.
- Write a basic DAX measure with SUM.
Fact tables and dimension tables
A star schema splits data into two kinds of table.
A fact table records events or measurements, one row per event. Examples are sales, transactions, and page views. It holds numeric columns you aggregate, plus key columns that point to dimensions.
A dimension table describes the things the events relate to, such as accounts, customers, products, or dates. It has one row per thing, a unique key, and descriptive columns you use to slice and filter.
| Property | Fact table | Dimension table |
|---|---|---|
| Row represents | An event | A business entity |
| Typical size | Large, grows over time | Small to medium |
| Key column | Repeats many times | Unique per row |
| Typical use | Summed or counted | Used for filters, rows, and columns |
The sample model
The tutorial uses a small banking model. Transactions is the fact table. Accounts and Dates are dimensions.
Each AccountID appears once in Accounts and many times in Transactions. The one side is the dimension. The many side is the fact table. The same holds for Dates.
Why the shape matters
Power BI filters flow along relationships. In a star schema, a filter on a dimension reaches the fact table through the one-to-many relationship. The default direction is from the one side to the many side.
Suppose a report shows Accounts[AccountType] in a table visual next to this measure:
Total Amount = SUM ( Transactions[Amount] )For the row Savings, the engine does the following:
- It filters
Accountsdown to the savings accounts. - It passes those
AccountIDvalues along the relationship toTransactions. - It sums
Amountover the matching transaction rows.
Each transaction belongs to exactly one account. The rows for all account types therefore add up to the grand total, with nothing missing and nothing counted twice. This property keeps the numbers correct and predictable. The later chapters on many-to-many relationships show how it can be lost.
Checking your own model
Before you add anything more complex, confirm the baseline:
- In Model view, check that each relationship goes from a dimension (one side) to the fact table (many side).
- Check that the dimension's key column has no duplicates.
- Put a dimension column and
[Total Amount]in a table visual. Confirm that the total row equals the sum of the rows above it.
If the model passes these checks, filters behave as described above. Use this model as your reference for comparison when relationships get more complicated.
Exercise
In the sample model, Transactions has 10,000 rows and Accounts has 200 rows. Which table is on the one side of the relationship on AccountID? Why will the account-level amounts add up to the grand total?
Show answer
Accounts is on the one side, because AccountID is unique there. Each transaction row matches exactly one account, so every amount is counted in exactly one account's total. The account totals therefore sum to the grand total.