Forum Discussion
Creating my own Date Table
- 1 year ago
Hi PaulKraemer
I would also recommend turning off auto date/time as a general rule, in line with what you've read.
If enabled, it creates a hidden table for every date column in the model (excluding calc tables/columns), which can significantly bloat the model size and harm performance.
I would recommend defining hierarchies yourself in your own Date table, whether created with DAX or Power Query.
As far as how to create the Date table:
- CALENDARAUTO may work fine in simple models, but because it searches the model for date columns and expands include all years spanning dates in those columns, it may become larger than required.
- There are various Power Query date table functions online. See here for example.
- If using DAX, I recommend instead using a pattern similar to this:
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ - You can also use the Bravo external tool to create a date table.
- If you would like to see an example of a Date table with hierarchies defined, you could download one of these Contoso Data Generator models from here.
For example download "pbix-100k.7z".
Hope that helps!
Hi OwenAuger and Neeraj -
Thank you very much for your thorough replies. As all of the Date columns in the Data Warehouse I am working with are of type Date, I will use a column of type Date to establish the relationships with my Date table.
I do have a follow up question. One of the advantages Neeraj pointed out for using Date columns is the automatic creation of hierarchies.
After I read the following article ...
https://learn.microsoft.com/en-us/power-bi/guidance/auto-date-time
... I got the impression that it might be to my advantage to turn off the auto-date-time option and use DAX to create my own Date table. I used CALENDARAUTO to create a calculated table. Then I added calculated columns for FiscalYear, FiscalQuarter, Month, etc.
As I start building my data model and creating some visuals, I would plan to establish relationships between this common Date table and my other tables that contain Date fields.
I am just getting started with Power BI, so I am sure there will be alot I can learn if I take this approach and fail, but if there is a different approach you would suggest, I would greatly appreciate it.
Thanks again!
Paul
Hi PaulKraemer
I would also recommend turning off auto date/time as a general rule, in line with what you've read.
If enabled, it creates a hidden table for every date column in the model (excluding calc tables/columns), which can significantly bloat the model size and harm performance.
I would recommend defining hierarchies yourself in your own Date table, whether created with DAX or Power Query.
As far as how to create the Date table:
- CALENDARAUTO may work fine in simple models, but because it searches the model for date columns and expands include all years spanning dates in those columns, it may become larger than required.
- There are various Power Query date table functions online. See here for example.
- If using DAX, I recommend instead using a pattern similar to this:
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ - You can also use the Bravo external tool to create a date table.
- If you would like to see an example of a Date table with hierarchies defined, you could download one of these Contoso Data Generator models from here.
For example download "pbix-100k.7z".
Hope that helps!
- PaulKraemer1 year agoAdvocate II
Thank you Owen - this is all very helpful !
I will be able to adapt my DAX (which currently makes use of CALENDARAUTO) to limit the range of dates to the ones I'm actually interested in for reporting purposes. I hadn't thought about the option of doing the same thing in Power Query, but I will try that also. (As I started trying to learn Power BI, I focused more on DAX than Power Query, but I'd like to become competent with both.)
Bravo seems like a useful tool also.
I do have a follow-up question about the Contoso sample you mentioned. I can see that there are hierarchies defined in Power BI. I was curious to see whether the Date table was created using DAX or Power Query, but when I opened Power Query Editor, it looks to me like the Date table is defined in an underlying SQL server database for which I don't seem to have credentials to access. Is the intent with these sample databases just to provide Power BI examples with data that was pulled from this database before the sample was made available? Or is it possible to connect to these back-end tables (for example to refresh report data).
I really appreciate your help.
Thanks again and best regards,
Paul