Sub topic 3
What a valid date table must contain
This chapter lists what a date table has to contain before time intelligence functions can rely on it. It assumes you can move around Power BI Desktop's Report, Table, and Model views. It also assumes you know what a relationship is, can write a basic DAX measure, and know the difference between fact and dimension tables. The next chapters build the table. Here you learn the rules it must satisfy and how to test them.
The rules in one place
Time intelligence functions such as TOTALYTD, SAMEPERIODLASTYEAR, and DATESINPERIOD don't look at your fact table. They take a column of dates, move or expand the set of dates, and apply the result as a filter. They can only move through dates that exist in that column. If a date is missing, the function can't reach it.
A date table that works for this has these properties:
| Property | What it means | What breaks without it |
|---|---|---|
| A date column of type Date | One column holds a real date value, not text or a number such as 20260115 | Marking the table fails, and functions can't interpret the values |
| Unique values | Each date appears exactly once | Marking fails, and the relationship can't be one-to-many |
| No blanks | Every row has a date | Marking fails |
| Contiguous | No day is skipped between the first and last date | Period shifts land on missing days and return blank or wrong totals |
| Whole years | The first row is January 1 and the last is December 31, or the first and last day of your fiscal year | Year-to-date and prior-year comparisons are incomplete at the edges |
| Covers the facts | Every date in every related fact column falls inside the range | Fact rows have no matching date and show up under a blank group |
| Consistent time part | If the type is Date/time, every row has the same time, normally midnight | Marking fails or relationships don't match |
The sections below take these in turn.
A real date column
The table needs one column whose data type is Date, or Date/time. In Power Query the type is type date. In DAX, CALENDAR and CALENDARAUTO return a column that Power BI treats as a date.
Text that looks like a date doesn't qualify. A value such as "2026-01-15" or an integer key such as 20260115 can't be used by time intelligence functions. An integer key is fine as an extra column for joins in a warehouse. Power BI still needs a true date column to mark and to pass into functions.
If you use Date/time, every row must have the same time portion, usually midnight. A table with 2026-01-15 00:00 and 2026-01-15 13:45 has two rows for one day, which breaks uniqueness at the day level.
Unique values and no blanks
The date column is the key of the dimension table. The relationship from the fact table to it is one-to-many, with the date table on the one side. That requires every date to appear once.
Duplicates usually come from building the table by stacking dates from several sources and not removing repeats. Blanks usually come from a join or an append that leaves an empty row. When you try to mark the table, Power BI rejects it and tells you the column contains duplicates or empty values.
No gaps
The table needs one row per calendar day between its first and last date. This is the rule people most often break, because the easiest table to build is one taken from the data.
Bad Date = DISTINCT ( Sales[OrderDate] )This table looks plausible and passes the uniqueness test. It only has days on which an order was placed. If no one ordered on a Sunday, that Sunday is missing. SAMEPERIODLASTYEAR for a date in the current year then lands on a day that isn't in the table, and the result for that day is blank or incomplete. The same applies to a table built from the last 30 days of transactions.
A table generated from a start and an end date, such as with CALENDAR or List.Dates, has no gaps by construction. Those are the methods the next two chapters use.
Whole years
The first date should be January 1 of some year and the last should be December 31 of some year. For a fiscal calendar, use the first and last day of fiscal years instead.
A table that starts on March 12 or ends on October 3 still has no gaps, so it can look correct. The problems show up at the edges:
- A year-to-date total for the first year starts from March 12, not January 1. Whether that's wrong depends on your data, but the table has silently decided that the year began on March 12.
- A prior-year comparison for dates in the second year points back into the partial first year. The result is incomplete without any error.
- Columns such as week of year or quarter total days are computed from a partial period.
Whole years also help with ordinary reports. A year slicer that lists 2027 with only three months of dates is confusing.
Covering the fact dates
The table must start no later than the earliest date in any related fact table and end no earlier than the latest. It should usually extend past the latest fact date to the end of the year, and further if you have forecasts or budgets.
Fact rows whose date falls outside the table don't disappear. They are grouped under a blank member of the date table, which is how Power BI handles relationships that don't match. Your totals stay correct, but a visual by year shows an unexpected blank row.
This is why the first code sample in the plan derives its range from the data:
Date =
CALENDAR (
DATE ( YEAR ( MIN ( Sales[OrderDate] ) ), 1, 1 ),
DATE ( YEAR ( MAX ( Sales[OrderDate] ) ), 12, 31 )
)The range follows the data and always lands on year boundaries. The tradeoff is that the table changes when the data changes. If you need a fixed range regardless of the data, use literal dates as in the second sample in the plan. If you have several fact tables, take the minimum and maximum across all of them.
If a fact column has a time part, such as 2026-01-15 13:45, the value won't match a midnight date in the date table. Create a date-only column in the fact table, for example in Power Query by changing the type to Date, and relate on that column.
Checking the rules with DAX
You can test each rule with measures. Add them to a card or table visual in a scratch report page, or put them in a DAX query view. They assume a table named Date with a Date column and a fact table named Sales.
Date Rows = COUNTROWS ( 'Date' )
Distinct Dates = DISTINCTCOUNT ( 'Date'[Date] )
Expected Days =
DATEDIFF ( MIN ( 'Date'[Date] ), MAX ( 'Date'[Date] ), DAY ) + 1
Unmatched Sales Rows =
COUNTROWS ( FILTER ( Sales, ISBLANK ( RELATED ( 'Date'[Date] ) ) ) )Read the results as follows:
Date Rows,Distinct Dates, andExpected Daysshould all be equal. IfDate Rowsis higher thanDistinct Dates, there are duplicates. IfExpected Daysis higher than both, there are gaps.Unmatched Sales Rowsshould be 0. A positive number means that many fact rows fall outside the date table or have a blank date.RELATEDneeds the relationship fromSalestoDate, so create it first.
To find the gaps themselves, make a temporary calculated table:
Missing Dates =
EXCEPT (
CALENDAR ( MIN ( 'Date'[Date] ), MAX ( 'Date'[Date] ) ),
SELECTCOLUMNS ( 'Date', "Date", 'Date'[Date] )
)The table lists every day in the range that has no row in Date. An empty result means no gaps. Delete this table afterward, because it has no use in the finished model.
You can check the whole-year rule by looking at the first and last dates:
First Date = MIN ( 'Date'[Date] )
Last Date = MAX ( 'Date'[Date] )For a calendar year table, First Date should show January 1 and Last Date December 31.
How these rules connect to marking
When you mark a table as the date table, you choose a date column and Power BI checks some of these rules. It checks the data type, uniqueness, and blanks. It can't check that you have whole years or that you cover your fact dates, because it doesn't know what range your reports need. Those two rules are your responsibility, so a table can be marked successfully and still give partial-year results. A later chapter covers the marking itself and what it changes in the model.
Exercise
You build a date table with DISTINCT ( Sales[OrderDate] ). It has no duplicates or blanks, and the column type is Date. Which two rules does it most likely break, and what symptom would you see in a prior-year measure?
Show answer
It most likely breaks the no-gaps rule, because days without orders are absent, and the whole-years rule, because it starts and ends on the first and last order dates instead of January 1 and December 31. A prior-year measure such as SAMEPERIODLASTYEAR then returns blank or incomplete values for days whose counterpart date is missing, and comparisons near the start of the first year and the end of the last year cover only part of the period.
Exercise
The measures Date Rows, Distinct Dates, and Expected Days show 2,557, 2,557, and 2,557, but Unmatched Sales Rows shows 412. What does this tell you, and what are two possible causes?
Show answer
The date table is unique and has no gaps, because all three counts match. The 412 fact rows have no matching date. Two possible causes are that the fact table has dates before the first date or after the last date of the date table, and that the fact column has a time portion, so its values don't equal the midnight dates in the date table. Check the minimum and maximum of the fact date column against the date table, and check whether the fact column has times.