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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
xoptopus
Regular Visitor

time transactions on powerbi

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.

 

xoptopus_0-1741761578344.png

 

8 REPLIES 8
v-sdhruv
Community Support
Community Support

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

v-sdhruv
Community Support
Community Support

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

v-sdhruv
Community Support
Community Support

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

Akash_Varuna
Super User
Super User

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])

 

rajendraongole1
Super User
Super User

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

 

Duration_Hours =
VAR StartTime = TIMEVALUE('timee'[Start_Time])  
VAR EndTime = TIMEVALUE('timee'[End_Time])  
RETURN DATEDIFF(StartTime, EndTime, MINUTE) / 60

 

rajendraongole1_0-1741763097060.png

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi @rajendraongole1 

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")

rajendraongole1_0-1741771989850.png

 

Hope this helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi @rajendraongole1 

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.

 

xoptopus_0-1741773469680.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors