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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi,
I want to find the difference between two hours as below and get the total over 24 hours. Then I need to use these hours in different statistics (such as finding percentages). What are the commands required to use the hour in mathematical expressions in this way? I ask for your help in this regard.
Hi @xoptopus ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please Accept it as a solution so other members can easily find it.
Thank You
Hi @xoptopus ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You
Hi @xoptopus ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You
Hi @xoptopus You could do this in Power Query and dax try this please which is in Power Query
Add a custom column:
Duration = Duration.From([End_Time] - [Start_Time])
Handle overnight times:
Duration = if [End_Time] >= [Start_Time]
then Duration.From([End_Time] - [Start_Time])
else Duration.From(#time(23, 59, 59) - [Start_Time]) + Duration.From([End_Time] - #time(0, 0, 0))
Format the result as hh:mm or convert it to hours as a decimal:
DecimalDuration = Duration.TotalHours([Duration])
Hi @xoptopus - Since time values are stored as fractions of a day in Power BI/Excel, use this formula to convert Duration to a decimal number
Proud to be a Super User! | |
Thanks for repply
So how do I finally convert it to hours? At the end of the day, I need to give the result in hours, not decimals.
Duration_HHMM =
VAR StartTime = TIMEVALUE('timee'[Start_Time])
VAR EndTime = TIMEVALUE('timee'[End_Time])
VAR TotalMinutes = DATEDIFF(StartTime, EndTime, MINUTE)
VAR Hours = QUOTIENT(TotalMinutes, 60)
VAR Minutes = MOD(TotalMinutes, 60)
RETURN FORMAT(Hours, "00") & ":" & FORMAT(Minutes, "00")
Hope this helps.
Proud to be a Super User! | |
Thanks for reply.
I take totals by measure. Totals of different areas. as below. How can I show this as hours. Total decimal numbers in a measurement.And total number higher than 24 hours should be displayed.