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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Alvim102
New Member

How to averege a time conversion

Hello guys, I have a column called talking_time but in seconds, I did a conversion using the formula below:

 

Talking Time =
var T = SUM([talking_time])
var H = INT(T / 3600)
var M = INT((T - (H * 3600)) / 60)
var S = MOD(T, 60)
return
H * 10000 + M * 100 +  S

And then I have the result like this 12:55:15 for example, but when I use the averege formula on [Talking Time] I have the result like 05:89:25, the minutes are wrong, the correct one is up to 59 and after that it adds an hour.
 
How can I fix this?
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Alvim102 

 

Talking Time =
VAR T =
    SUM ( 'Table'[talking_time] )
VAR H =
    FORMAT ( QUOTIENT ( T, 3600 ), "00" )
VAR M =
    FORMAT ( QUOTIENT ( MOD ( T, 3600 ), 60 ), "00" )
VAR S =
    FORMAT ( MOD ( MOD ( T, 3600 ), 60 ), "00" )
RETURN
    H & ":" & M & ":" & S

 

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Alvim102 

 

Talking Time =
VAR T =
    SUM ( 'Table'[talking_time] )
VAR H =
    FORMAT ( QUOTIENT ( T, 3600 ), "00" )
VAR M =
    FORMAT ( QUOTIENT ( MOD ( T, 3600 ), 60 ), "00" )
VAR S =
    FORMAT ( MOD ( MOD ( T, 3600 ), 60 ), "00" )
RETURN
    H & ":" & M & ":" & S

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors