The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi please help, how to write the DAX formula to generate a list like the following running day number + 24 hours for the whole year (day 366), maybe includes seconds in every hours...
Day 1, 0:00
Day 1, 1:00
Day 1, 2:00
.....
Day 1, 23:00
Day 2, 0:00
Day 2, 1:00
...
Day 366, 23:00
Thank you for any tips:)
Solved! Go to Solution.
I would usually do this in the query editor with M, but here is one way to do it with DAX.
DateHour =
ADDCOLUMNS (
ADDCOLUMNS (
GENERATESERIES ( 0, 365 * 24, 1 ),
"DateTime",
DATE ( 2023, 1, 1 )
+ ROUNDDOWN ( [Value] / 24, 0 )
+ TIME ( [Value], 0, 0 )
),
"Day", DAY ( [DateTime] ),
"DayHr",
"Day " & DAY ( [DateTime] ) & ", "
& HOUR ( [DateTime] ) & " hr"
)
Pat
Thank you Pat:) Would be nice to know the same in M too, if you have time.
I would usually do this in the query editor with M, but here is one way to do it with DAX.
DateHour =
ADDCOLUMNS (
ADDCOLUMNS (
GENERATESERIES ( 0, 365 * 24, 1 ),
"DateTime",
DATE ( 2023, 1, 1 )
+ ROUNDDOWN ( [Value] / 24, 0 )
+ TIME ( [Value], 0, 0 )
),
"Day", DAY ( [DateTime] ),
"DayHr",
"Day " & DAY ( [DateTime] ) & ", "
& HOUR ( [DateTime] ) & " hr"
)
Pat