Forum Discussion
Changing decimal number into Duration
hi Anonymous ,
Use
Duration.TotalSeconds([TT_Finished] - [TT_Started])
so your duration will be in seconds then you can follow the post from Greg_Deckler
Hi mussaenda,
Thanks for getting back to me! Unfortuantly that didn't work! I got an error where some of the Finished dates return blanks.
I tried to use the Try Otherwise function. But this just returned the "otherwise" value for all rows.
- Greg_Deckler6 years ago
Community Champion
Anonymous - It looks like you are getting back a value that is essentially the decimal portion of a day (24 hours). In DAX, you could get that duration in seconds using the following:
Column = ([Finished] - [Started]) * 1. * 24 * 60 * 60
So, Finished - Started and you multiply by 1. to get a decimal value. You then multiply this by 24 to get the number of hours, 60 to get the number of minutes and then 60 again to get the number of seconds.
- mussaenda6 years ago
Community Champion
Hi Anonymous ,
As you can see, I used an If Else for the null then it's okay.
Then in Dax, I transformed it to duration time format which I also found here in the forum.
Core Time_Seconds Measure = SUM('Table'[Core Time_Seconds])Duration Format Time_Employee Measure = VAR hours = ROUNDDOWN ( [Core Time_Seconds Measure] / 3600, 0 ) VAR minutes = ROUNDDOWN ( MOD ( [Core Time_Seconds Measure] , 3600 ) / 60, 0 ) VAR seconds = INT ( MOD ( [Core Time_Seconds Measure] , 60 ) ) RETURN FORMAT(hours,"00") & ":" & FORMAT(minutes, "00") & ":" & FORMAT(seconds, "00")