Sub topic 3
Marking the table as the date table
Assume you know basic Power BI navigation, DAX measures, and model relationships. This chapter focuses on configuring and validating an existing daily date table.
Marking the table as the date table
In Model view, select the date table. On the Table tools tab, choose Mark as date table, then select its Date column. Power BI checks that the column contains unique, nonblank dates.
The table should contain one row for every date in its covered range. Its Date column must use the Date data type. Relate this column on the one side of a one-to-many relationship to the matching date column in a fact table.
Using the table in time intelligence measures
Use the marked table's date column in time-intelligence functions, rather than a date column from the fact table.
Total Sales = SUM ( Sales[Amount] )
Sales YTD =
TOTALYTD ( [Total Sales], 'Date'[Date] )
Sales PY =
CALCULATE (
[Total Sales],
SAMEPERIODLASTYEAR ( 'Date'[Date] )
)A relationship lets a filter on 'Date'[Date] flow to Sales. If a visual uses a month from the fact table, these measures may not evaluate as intended.
Adding a fiscal calendar
For a fiscal year ending June 30, add fiscal attributes and specify the year end in the measure.
Fiscal Year = YEAR ( EDATE ( [Date], 6 ) )
Fiscal Month Number =
MOD ( MONTH ( [Date] ) - 7, 12 ) + 1
Sales Fiscal YTD =
TOTALYTD ( [Total Sales], 'Date'[Date], "6/30" )Sort fiscal month names by Fiscal Month Number, just as calendar month names should be sorted by Month Number.
Handling order, ship, and due dates
A fact table can contain several date columns. Keep one active relationship, usually OrderDate, and make the others inactive. Activate a specific relationship inside a measure.
Sales by Ship Date =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)Checking the table and fixing common problems
Test the model with a table visual containing Date, Year, and Month. Check these conditions:
- Dates have no gaps, duplicates, blanks, or time portions.
- The relationship is active and points from Date to the fact table.
- Month and quarter labels use numeric sort columns.
- YTD resets at the expected calendar or fiscal boundary.
- Prior-year results exist only where the matching prior period exists.
Exercise
Sales YTD is blank or incorrect when the visual uses Date[Month]. What should you check first?
Show answer
Check that Date[Date] is marked as the date table, related actively to the fact table's date column, and used in the measure's time-intelligence expression.