DAX - Common Date Table Flashcards
What is the risk of not using a common date table?
The different fact tables might represent dates differently.
Making it difficult to compare different dates
What is another name for a common date table?
A Date Dimension table
What is the common date table necessary for?
Using time intelligence functions
What specs must the common date table meet?
- One record per day
- NO missing or blank dates
- Minimum and Maximum dates must cover what you will use in your calculations
What are two functions you can use to create a common date table?
- CALENDAR
- CALENDARAUTO
CALENDAR syntax
CALENDAR(StartDate, EndDate)
CALENDAR example
Date=CALENDAR
(
DATE(2017, 1, 1),
DATE(2021, 12, 31)
)
Just writing a long sentence so the formula will left justify
What do you need to do after you’ve created a common date table?
Mark as Date table in Power BI
What does “mark as date table” do?
Overrides the Power BI’s auto generated date dimension for all time intelligence and date based calculations in DAX within the data model.
Where do you go to create a Common Date Table in M?
In the Transform Data area:
Home tab->New Source->Blank Query
Create Common Date Table M syntax
=List.Dates(#date(2017, 01, 01), 365*5, #duration(1, 0, 0, 0))
This creates a 5 year date table starting at 1/1/2017
What is the #duration syntax?
duration(days, hours, minutes, seconds)
What is the List.Dates syntax?
List.Dates(Start as Date, Count as Number, Step as Duration)
How do you change the dates list created by going to New Source->Blank Query and using the List.Dates formula to a table?
Tranform Tab->To Table
What must you do after creating a common date table using PowerQuery M?
Change the date column you created to have a date format.