Sub topic 8
Relating the Date Table to Your Fact Table
This chapter assumes you can move around Power BI Desktop's Model view, know the difference between a fact table and a dimension table, and can read basic DAX. The date table is a dimension. Here you connect it to a fact table so that filters on dates flow into your measures.
Why the relationship matters
A date table filters nothing until it is related to a fact table. If you place 'Date'[Year] on a chart axis next to [Total Sales] without a relationship, every year shows the same grand total. The date table has no path to the Sales rows.
The relationship is also what time intelligence functions depend on. TOTALYTD and SAMEPERIODLASTYEAR build a set of dates from the date table. They then apply that set as a filter to the fact table through the relationship. If the relationship is missing or points at the wrong column, those functions return blanks or wrong totals.
The shape you want
The standard design is a star schema. One date table sits at the center of the date filtering, and each fact table joins to it:
- The date table is on the "one" side.
- The fact table is on the "many" side.
- Filters flow from the date table to the fact table (single direction).
- The relationship is active.
Matching the join columns
The join uses one column from each table:
- In the date table, use the
Datecolumn. Its values are unique, one per day. - In the fact table, use the date column you want to analyze by, such as
Sales[OrderDate].
Both columns should have the Date data type, not Date/Time. This is the most common source of broken relationships. If the fact column contains time values such as 2026-03-05 14:32:00, those rows do not match the date table's 2026-03-05 00:00:00. The rows then fall outside any date and are grouped under a blank.
Check the data type in the Column tools ribbon. If OrderDate carries a time portion you do not need, remove it in Power Query by changing the type to Date. That keeps the original precision of the fact table intact in the model only if you also keep a separate column for the time. If you need the time of day, add a separate time column first.
If you cannot change the type in the source, a calculated column works as a fallback:
Order Date Only = INT ( Sales[OrderDate] )INT drops the fractional part of the underlying number, which is the time of day. Set the column's type to Date afterward and relate on this column. Prefer fixing the type in Power Query, since a calculated column adds storage and refresh work.
Creating the relationship
You can create the relationship in several ways. All of them produce the same result.
- Open Model view.
- Drag
'Date'[Date]ontoSales[OrderDate]. - Double-click the line between the tables to open Edit relationship.
- Confirm these settings:
- Cardinality: One to many (1:*), with
Dateon the one side. - Cross-filter direction: Single.
- Make this relationship active: selected.
- Select Save.
You can also use Manage relationships on the Modeling ribbon and select New. Power BI often detects a match and creates the relationship for you when the column names and types agree. Always open it and check it. Autodetection can pick a different column than the one you want.
Cardinality and direction
| Setting | Value to use | What goes wrong otherwise |
|---|---|---|
| Cardinality | One to many, date table on the one side | Many-to-many appears when the date column has duplicates. Filters become ambiguous and the table cannot be marked as a date table. |
| Cross-filter direction | Single, from date to fact | Both directions can create ambiguous paths when several fact tables share the date table, and they slow queries. |
| Active | Yes for the main date column | An inactive relationship is ignored unless a measure calls `USERELATIONSHIP`. |
If Power BI proposes many-to-many, stop and look at the date table. The Date column must contain no duplicates. A date table built with CALENDAR or List.Dates cannot contain duplicates. A table imported from another source might.
Blank rows and out-of-range dates
When a fact row has a date that does not exist in the date table, Power BI keeps the row. It assigns the row to a virtual blank member on the one side. You see this as a (Blank) entry in a slicer or a visual, and the amounts under it are real sales that fell outside the calendar.
Two causes are common:
- The date table does not cover the full range of the fact data. A table that ends at
2026-12-31cannot hold an order dated2027-01-02. - The fact column has empty values. A missing ship date, for example, is a legitimate blank.
The first cause is a modeling error. The CALENDAR expression from the earlier chapter, built from MIN and MAX of the sales dates, avoids it by covering whole years. If you hard-code the range, as in CALENDAR ( DATE ( 2020, 1, 1 ), DATE ( 2026, 12, 31 ) ), you must extend it when data arrives beyond the end date.
The second cause is expected, and the blank row is correct. Do not fill missing dates with a placeholder such as 1900-01-01. That would stretch the date table backward and distort year ranges.
Hiding the fact table's date column
Once the relationship exists, report authors should use 'Date'[Date] and the other date table columns, not Sales[OrderDate]. Using the fact column in a visual axis bypasses the calendar attributes and causes Power BI to build a date hierarchy automatically if automatic date/time is still enabled.
To prevent this, hide Sales[OrderDate] from Report view. In Model view, select the column and set Is hidden to Yes in the Properties pane. Hiding does not break the relationship or any measure that references the column. It only removes the column from the field list.
Be careful with this step if you have several date columns. Hide only columns that have a related counterpart in the date table. A column you still need for a calculation, such as a ship date used with USERELATIONSHIP, can be hidden too, because hidden columns remain usable in DAX.
Relating more than one fact table
A date table can serve many fact tables. Create one relationship from 'Date'[Date] to the date column of each fact table, for example Sales[OrderDate] and Budget[BudgetDate]. The date table then works as a shared filter, so a single Year slicer filters both facts at once.
Keep each of these relationships single direction. Date to fact is enough, and it avoids ambiguity between the fact tables.
If a second fact table has a different grain, such as a budget stored monthly with the first of each month as the date, the relationship still works. Each budget row matches the first day of its month. Measures on that fact then show values only on those days unless you aggregate by month. Take this into account when you design the visuals, because a daily line chart of budget values will look like a series of isolated points.
Several date columns in one fact table
A Sales table often has OrderDate, ShipDate, and DueDate. Power BI does not allow more than one active relationship between the same two tables. You have two designs:
- One date table, one active relationship, other relationships inactive. The date table has a single active relationship to
OrderDate. Relationships toShipDateandDueDateare created but inactive. A measure activates one when needed withUSERELATIONSHIP. - One date table per role. You duplicate the date table and rename the copies, such as
Ship Date. This costs more memory, but report authors can drop fields directly into visuals without special measures.
A later chapter covers this topic in depth. For now, create the extra relationships the same way, then clear Make this relationship active. Power BI creates the extra ones as inactive on its own when an active one already exists between the same tables. The measure below uses an inactive relationship to ship date:
Sales by Ship Date =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)Checking the relationship
After creating the relationship, test it before building any measures.
- In Report view, add a table visual.
- Place
'Date'[Year]and'Date'[Month]in the table. - Add a measure such as
[Total Sales]. - Check three things. The values differ by row. The grand total equals the total of the fact table with no date filter. No
(Blank)row appears, unless the fact table has missing dates.
If every row shows the same value, the relationship is missing, inactive, or joined on the wrong column. If the total of the rows is lower than the grand total, some fact dates fall outside the date table.
Common errors
- Many-to-many relationship proposed. The date column in the date table has duplicates, or you selected the wrong column on the one side.
- Relationship cannot be created because of a type mismatch. One column is Date and the other is Text. Convert the text column in Power Query.
- Blank row in visuals. The fact table has dates outside the calendar range, or has blank dates.
- Same value on every row. The relationship is inactive, points at a different column than the one in use, or has the wrong filter direction.
- Time intelligence returns blanks. The relationship uses a Date/Time column with times, so the dates never match.
Exercise
A Sales table has an OrderDate column with values such as 2026-03-05 14:32:00. You relate it to 'Date'[Date], but a visual with 'Date'[Year] and [Total Sales] shows only a (Blank) row with the full total. What is the cause, and what is the fix?
Show answer
The fact column holds date and time values, so none of them equal the date table's midnight-only values and every row falls into the blank member. Change OrderDate to the Date type in Power Query, which removes the time portion, and refresh. If you need the time of day, first copy it to a separate time column. After the change, the rows match the date table and the Year values split the total correctly.
Exercise
You relate 'Date'[Date] to both Sales[OrderDate] and Sales[ShipDate]. Which relationship is active, and how does a measure use the other one?
Show answer
Only one relationship between the same two tables can be active. Keep the one on OrderDate active, and leave the ShipDate relationship inactive. A measure activates the inactive one with CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ) ).