In a previous post, I wrote about the fact that Power BI did not have the capability to Mark a table as date, but that has changed! Now if you want a date table to use numeric keys to join to other tables you can and still get the time dimension functionality to work. Now there is no need to use some kind of a work around to get a date table, you can just make it one.
Marking a Date Table in Power BI
Naturally there is more than one way to mark a table as a date table in Power BI. The first way is to click on the ellipse (you know the three dots) next to the date table Name in the Power BI Fields, which I highlighted in yellow. The menu contains an option to Mark as date table. If you select say the locations table, Power BI is smart enough to know that this is not a date table and the option will not appear. The first time that you select the table it will show the window shown above and prompt you to select the column in the table which is an actual value. Once you select the OK button, the menu item will have a check mark next to the Mark As Date Option and if you select it again you will see this window. Generally speaking there is no reason to Unmark a date table, but if you want to, you can.
The other place in Power BI where you can Mark a Date table is in the report view there is an option in the Modeling tab to Mark as Date Table. Note this option will be disabled unless you have clicked on a table first. The icon is only available in the Modeling tab of the report view. If you are in the grid view or the relationship view you won’t see the option to Mark as Date Table, it is only available in the Report Modeling tab.
Time Dimension Functions: The reason for marking a Date Table
For those of you who may be wondering: Why would I want to mark a table as a date anyway there is a very good reason. Marking a table as a date allows you to use all of the cool features which Microsoft added to DAX to do date calculations for you. While it is possible to not use any time based DAX functions, unless you are rather expert at DAX, like these guys, you probably will want to use the nice DAX functions Microsoft created for handy things like TOTALYTD or SAMEPERIODLASTYEAR. Now just because you have a date table added does not mean that you can use any date in those calculations, you need to reference a table that you have marked as date, not a date field within the table. That means that CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(DateTime[DateKey])) will return the correct value and CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(ResellserSales[DateKey])) will not. You need to reference the table marked as a date table every single time in for Time Dimensions. For and example of a Power BI Desktop DAX calculation not working when you are not using a marked date table, check out this post.
Power BI Update Requests
Power BI updates every month and you may miss some of the things that the team released last month if you do not check out this site every month. I know that the Power BI teams takes ideas for upcoming releases from Https://ideas.powerbi.com, and there is one thing that I really wish would get some more votes so that it can be added soon, which is another idea, like Marking Date Tables, which started out in SSAS Tabular. Having recently worked on a project with a ton of measures. The next feature that I hope that Power BI inherits from SSAS tabular is the ability to create folders for measures. If you would like that too, vote for it here.
Yours Always,
Ginger Grant
Data aficionado et SQL Raconteur