Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dax round of datetime

Hi all,

 

Working in Live Connect (so I cannot seperate columns), I have a datetime column in the following 24H format: "YYYY-MM-DD HH:MM:SS.ttt", e.g. "2019-05-13 15:18:40.963".

 

I'm trying to make a measure summing the sales in the previous full hour, assuming I have a measure returning the max value in that column (max(Updatetime)).

So in the about example, the sum of sales will be for the time between "2019-05-13 14:00:00.000" (bottom) and "2019-05-13 14:59:59.999 (top)".

 

My problem is finding the top and bottom boundries using dax and keeping them in the same datetime format.

 

Any assistance would be welcome.

Thank you!

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please see the below DAX expression, you should be able to adjust it to what you need and then add extra calculation to obtain sum .

Your Measure = 
VAR dateTime = NOW() -- Your max(Updatetime)
VAR TimeEnd = DATEVALUE(dateTime) + TIME(INT(TIMEVALUE(dateTime) * 24), 0, 0)
VAR TimeStart = TimeEnd - TIME(1, 0, 0)
RETURN TimeStart & " - " TimeEnd

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please see the below DAX expression, you should be able to adjust it to what you need and then add extra calculation to obtain sum .

Your Measure = 
VAR dateTime = NOW() -- Your max(Updatetime)
VAR TimeEnd = DATEVALUE(dateTime) + TIME(INT(TIMEVALUE(dateTime) * 24), 0, 0)
VAR TimeStart = TimeEnd - TIME(1, 0, 0)
RETURN TimeStart & " - " TimeEnd

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

This works perfectly, thank you!

much more elegant than I initially thought.
I tried using "left", "datepart", "format", "datevalue" and other workarounds and failed.

 

So thanks a lot!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors