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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AZJohnPowerBI
Helper I
Helper I

Seconds to Minutes and Seconds

I have several columns that I converted the dates to seconds and I want them to be formated as mm:ss.

 

I have tried using

 

 

Var Duration = [Avg Speed of Answer in Seconds]
// There are 3,600 seconds in an hour
VAR Hours = INT ( Duration / 3600)
// There are 60 seconds in a minute
VAR Minutes = INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
// Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours 
VAR Seconds = ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0) // We round up here to get a whole number
RETURN
// We put the hours, minutes and seconds into the proper "place"
Hours * 10000 + Minutes * 100 + Seconds

 

as my code and when that didn't work I tried using 

 

= Duration in Minutes and Seconds =
var _Seconds = [Avg Talk Time in Seconds]
var _Minutes = int(_Seconds/60)
var _RemainingSeconds=MOD(_Seconds, 60)
var _RemainingMinutes=MOD(_Minutes, 60)
return 
_Minutes&" Minutes & " &_RemainingSeconds& "Seconds"

 

 but neither one is helping, any ideas? Any help would be greatly appreciated

I want to go from this:

seconds
09
256

 

to

Duration
00:09

4:16

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Please see this article/videos for a good flexible way to calculate and format durations (w/o having to separately calculate sec, min, hr, etc.).

 

Calculate and Format Durations in DAX – Hoosier BI

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for your post. Over the weekend I found a formula that end up working.

Not Ready Time = //this formula converts the seconds into days:hours:minutes:seconds
//the code on line 2 displays days
RIGHT("0" & INT ( 'FACT Agent'[Not Ready Time in Seconds]/86400 ), 2) & ":"
  //hours
    & RIGHT ( "0" & INT ( 'FACT Agent'[Not Ready Time in Seconds] / 3600 ), 2 ) & ":"
//minutes
    & RIGHT ( "0" & INT ( ('FACT Agent'[Not Ready Time in Seconds]  - INT ('FACT Agent'[Not Ready Time in Seconds]  / 3600 ) * 3600 ) / 60 ), 2 ) & ":"
    //seconds
    & RIGHT ( "0" & MOD ('FACT Agent'[Not Ready Time in Seconds] , 3600 ), 2 )
I'll be looking through articles more since most of the questions I have are probably already answered somewhere on the Power BI community. Thank you for all your posts, they're very helpful for newbies like myself!!
amitchandak
Super User
Super User

@AZJohnPowerBI , Time to second

 

In sec=

hour([Duration]) *3600 + Minute([Duration]) *60 + second([Duration]) 

 

 

Second to time

time(0,0,[In sec])

 

or

time(Quotient([In sec],3600) ,  Quotient(Mod([In sec],3600),60) ,Mod(Mod([In sec],3600),60) )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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