Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
So I am working with a model that is used in an embedded instance. It was created with 1 datetime table that actually has dates and times together. Which results in duplicate dates. Which as you know makes it so I can't use time intelligence functions such as YTD, MTD and so on.
Was wondering if there was a way I could create a hidden date table that doesn't have duplicates and is joined (maybe?) to the current date table so that it is filtered when that is filtered. Then when users utilize the fields in create datetime it will work with time intelligence?
I've tried this but it's not working 100%... So maybe I have to add another table for users to use, but I would prefer not to.
What I tried
and my simple dax
Is this even possible?
It sounds like it should work in theory. There are a couple requirements for time intelligence to work full like marking the new table as the date table and having it include full years of dates (1/1 - 12/31).
https://learn.microsoft.com/en-us/power-bi/guidance/model-date-tables
Is there any way you can split your current date table, the one that had date + time into two, a date table with only dates and a time table with just times? I have used this technique and it works well. A time table down to the second granularity only has 86,400 rows. You create it using a time key that looks like this '00:00:01' - '23:59:59'
Then, on your data side you split the datetime columns into date and time and join it to the date table and the time table.
I will even share the SQL code for the time talbe I use:
WITH Tally ([Second]) AS
(
SELECT
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1 -- zero-based
-- Returns exactly 86400 rows (number of seconds in a day)
FROM (VALUES(0),(0),(0),(0),(0),(0)) a(n) -- 6 rows
CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) b(n) -- x12 rows
CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) c(n) -- x12 rows
CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) d(n) -- x10 rows
CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e(n) -- x10 rows
) -- = 86,400 rows
SELECT
RIGHT('0' + CAST ([Second] / 3600 AS VARCHAR(2)),2) + ':' + RIGHT('0' + CAST ([Second] / 60 % 60 AS VARCHAR(2)),2) + ':' + RIGHT('0' + CAST ([Second] % 60 AS VARCHAR(2)),2) [Time_Key],
[Second],
[Second] / 3600 [Hour Number],
[Second] / 60 % 60 [Minute Number],
[Second] % 60 [Second Number],
FORMAT ( DATEADD(second,[second],0), 'h:mm tt') [Hour Minute AM/PM],
FORMAT ( DATEADD(second,[second],0), 'HH:mm') [Hour Minute 24],
FORMAT ( DATEADD(second,[second],0), 'h tt') [Hour AM/PM],
FORMAT ( DATEADD(second,[second],0), 'HH:00') [Hour 24],
CASE
WHEN [second] BETWEEN 0 AND 21599 THEN
'12 AM to 6 AM'
WHEN [second] BETWEEN 21600 AND 43199 THEN
'6 AM to 12 PM'
WHEN [second] BETWEEN 43200 AND 64799 THEN
'12 PM to 6 PM'
WHEN [second] BETWEEN 64800 AND 86399 THEN
'6 PM to 12 AM'
ELSE
null
END [Hourly Quartile],
CASE
WHEN [second] BETWEEN 0 AND 21599 THEN
'12 AM'
WHEN [second] BETWEEN 21600 AND 43199 THEN
'6 AM'
WHEN [second] BETWEEN 43200 AND 64799 THEN
'12 PM'
WHEN [second] BETWEEN 64800 AND 86399 THEN
'6 PM'
ELSE
null
END [Hourly Quartile Short],
CASE
WHEN [second] BETWEEN 0 AND 21599 THEN
1
WHEN [second] BETWEEN 21600 AND 43199 THEN
2
WHEN [second] BETWEEN 43200 AND 64799 THEN
3
WHEN [second] BETWEEN 64800 AND 86399 THEN
4
ELSE
99
END [Hourly_Quartile_Sort]
FROM Tally
Appreciate it. I may just use your code. I'm going to look into splitting it. Didn't want to because this is an established model with the one datetime in it but I don't see the harm in creating a "Date" table as well. I always get the "Our customers will get confused" argument....
I already have a newer model that I created with a split out date and time table. So this wouldn't be new to people anyways.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 33 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 127 | |
| 116 | |
| 90 | |
| 73 | |
| 69 |