Power Pivot & DAX course · Lesson 2 of 16
The Data Model and relationships: star schema and filter direction
Fact and dimension tables, the star schema, one-to-many relationships, how filters flow from the one side to the many side, and active vs inactive links.
A model is only as good as its relationships. Get them right and every PivotTable, measure and slicer behaves; get them wrong and numbers repeat, totals stop adding up and the yellow Relationships may be needed banner haunts you. This lesson explains how the Data Model connects tables, why the star schema is the shape to aim for, and which way filters travel along a relationship.
Fact tables and dimension tables
Look at any business data set and you will find two kinds of table:
- Fact tables record events: sales, payments, website visits, timesheet entries. They are long (many rows), narrow, and mostly made of numbers plus key columns that say who, what and when.
- Dimension tables (also called lookup tables) describe the things involved in those events: products, customers, stores, dates. They are short, have one row per item and contain the descriptive text you want to group and filter by.
Our running example has one fact table and two dimensions:
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | OrderID | Date | CustomerID | ProductID | Qty | Amount |
| 2 | 1001 | 2026-01-05 | C1 | P1 | 2 | 1900 |
| 3 | 1002 | 2026-01-12 | C2 | P2 | 10 | 120 |
| 4 | 1003 | 2026-01-20 | C3 | P3 | 3 | 567 |
| 5 | 1004 | 2026-02-02 | C1 | P4 | 5 | 175 |
| 6 | 1005 | 2026-02-09 | C4 | P5 | 4 | 1680 |
| 7 | 1006 | 2026-02-17 | C2 | P1 | 1 | 950 |
| 8 | 1007 | 2026-03-03 | C3 | P2 | 20 | 240 |
| 9 | 1008 | 2026-03-10 | C4 | P3 | 2 | 378 |
| 10 | 1009 | 2026-03-18 | C1 | P5 | 1 | 420 |
| 11 | 1010 | 2026-03-25 | C2 | P4 | 6 | 210 |
Fact table Sales. CustomerID and ProductID are foreign keys: they point to rows in the dimension tables.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | ProductID | Product | Category | Price | Cost |
| 2 | P1 | Laptop | Computers | 950 | 700 |
| 3 | P2 | Mouse | Accessories | 12 | 5 |
| 4 | P3 | Monitor | Displays | 189 | 120 |
| 5 | P4 | Keyboard | Accessories | 35 | 18 |
| 6 | P5 | Tablet | Computers | 420 | 300 |
Dimension table Products. ProductID is unique: the primary key.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | CustomerID | Customer | Region | Segment |
| 2 | C1 | Anna Weber | North | Consumer |
| 3 | C2 | Brook Dental | South | Business |
| 4 | C3 | Carter & Co | East | Business |
| 5 | C4 | Delta Schools | West | Business |
Dimension table Customers. CustomerID is unique: the primary key.
The star schema
When you draw this in Diagram View, the fact table sits in the middle and each dimension connects to it, like the points of a star. That is the star schema, and it is the layout the engine is optimised for. A few practical rules follow from it:
- Every dimension table has a column with unique values (the key).
- The fact table contains that key, repeated as often as needed, and the numbers to aggregate.
- Descriptive columns (Category, Region, Segment) live in the dimensions, not in the fact table.
- Dimensions do not connect to each other directly. Products and Customers are related only through Sales.
- Later you add a Calendar dimension the same way (see Building a calendar (date) table for Power Pivot).
A snowflake is a star whose dimensions have their own sub-dimensions, for example Products → Categories → Departments. The model handles snowflakes, but every extra hop costs some speed and makes DAX longer. If a sub-dimension is small, it is usually better to merge it into the main dimension during import (Power Query's Merge Queries is ideal for that).
One-to-many relationships
Each relationship in an Excel Data Model joins one column on the one side (a dimension's unique key) to one column on the many side (the fact table's foreign key). In Diagram View you see a 1 at the dimension end and a * at the fact end. Excel's Data Model supports only this one-to-many type (and one-to-one, which behaves the same way); there is no many-to-many relationship in Excel.
Creating a relationship from the Excel ribbon
- Make sure both tables are in the model (lesson Importing data into the Data Model: tables, Power Query and databases shows how).
- Choose Data › Data Tools › Relationships and click New….
- Table:
Sales; Column (Foreign):ProductID. - Related Table:
Products; Related Column (Primary):ProductID. - Click OK, then repeat with
Sales[CustomerID]→Customers[CustomerID].
Creating a relationship in Diagram View
- Open Power Pivot › Data Model › Manage, then Home › View › Diagram View.
- Drag the
ProductIDcolumn from the Sales box and drop it ontoProductIDin the Products box. - A line appears. Click it to highlight the two joined columns; double-click it to open Edit Relationship.
Inside the Power Pivot window you can also use Design › Relationships › Create Relationship and Manage Relationships, which lists every relationship with buttons to edit, delete or activate it.
1001 as a number in one table and as text in the other). Check the types in the Power Pivot window with Home › Formatting › Data Type before relating.Filter direction: which way do filters flow?
A relationship is not just a link; it is a one-way street for filters. In an Excel Data Model a filter always flows from the one side to the many side: from Products to Sales, from Customers to Sales. In Diagram View the arrow on the line shows the direction.
When you put Products[Category] on rows and the PivotTable shows the Accessories row, the engine filters Products to the Mouse and Keyboard rows, follows the relationship and keeps only the Sales rows for P2 and P4. Every measure in that row is then calculated on those Sales rows. That is why the following PivotTable, with Segment from Customers and Category from Products, works even though neither dimension knows anything about the other:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Segment | Accessories | Computers | Displays | Grand Total |
| 2 | Business | 570 | 2630 | 945 | 4145 |
| 3 | Consumer | 175 | 2320 | 2495 | |
| 4 | Grand Total | 745 | 4950 | 945 | 6640 |
Sum of Amount by Customers[Segment] (rows) and Products[Category] (columns). Both filters meet in the Sales table.
The filter does not travel the other way. Sales cannot filter Products, and Products cannot filter Customers by passing through Sales and coming out the other side. Here is a demonstration with two measures (you will learn to write them in Your first DAX measures: SUM, AVERAGE, COUNTROWS, DISTINCTCOUNT):
Customer Count := COUNTROWS ( Customers )
Buying Customers := DISTINCTCOUNT ( Sales[CustomerID] )| A | B | C | |
|---|---|---|---|
| 1 | Category | Customer Count | Buying Customers |
| 2 | Accessories | 4 | 3 |
| 3 | Computers | 4 | 3 |
| 4 | Displays | 4 | 2 |
| 5 | Grand Total | 4 | 4 |
Products[Category] on rows. Customer Count ignores the category; Buying Customers responds to it.
Customer Count shows 4 in every row. The Category filter lands on Products, flows down to Sales and stops: it never reaches Customers, because that would mean travelling from the many side (Sales) up to the one side (Customers). Buying Customers counts distinct customer IDs inside Sales, which is filtered, so it gives the real answer: for example only Carter & Co and Delta Schools bought Displays, hence 2. Notice also that the grand total of Buying Customers is 4, not the sum of the rows: distinct counts never add up.
CROSSFILTER inside CALCULATE for that one measure (Excel 2016 and later).Active and inactive relationships
Between two tables only one relationship path can be active at a time. Suppose Sales had both an OrderDate and a ShipDate and you relate both to a Calendar table. Excel makes the first relationship active (solid line) and the second inactive (dotted line). PivotTables always use the active one. A measure can switch to the inactive one temporarily with USERELATIONSHIP inside CALCULATE:
Shipped Amount := CALCULATE ( SUM ( Sales[Amount] ), USERELATIONSHIP ( Sales[ShipDate], 'Calendar'[Date] ) )You can activate or deactivate a relationship in Design › Manage Relationships inside Power Pivot, or by right-clicking its line in Diagram View.
Checklist for a healthy model
- One fact table per kind of event; several dimension tables around it.
- Every relationship goes from a fact table's key to a dimension's unique key.
- Matching data types on both sides of each relationship.
- No relationships between dimensions; no circular paths.
- Hide the foreign key columns in the fact table (right-click › Hide from Client Tools) so people use the dimension columns instead. You will see why in the next lessons.
Check yourself
1. In a star schema, where does the Category column belong?
Descriptive attributes live in the dimension that describes the item.
2. Which way does a filter flow along an Excel Data Model relationship?
Filters flow from the dimension (one) to the fact table (many).
3. Why does COUNTROWS(Customers) show the same number in every Category row?
Products filters Sales, but Sales does not filter Customers.
4. What happens when two relationships connect Sales and Calendar?
Only one path can be active; measures can switch with USERELATIONSHIP.
5. Excel refuses to create a relationship. What is the most likely cause?
The one side must contain unique keys.