Forum Discussion
Anonymous
5 years agoNot applicable
Chelsie Eidens Duration
Hey guys, i am using Chelsie Eidens Duration to aggregate time and I only need to take off seconds and show hour and minute, any ideas? If I simply format as 00:00 it does time like 406:00
The code is as follows:
Chelsie Eiden's Duration = // Duration formatting // * @konstatinos 1/25/2016 // * Given a number of seconds, returns a format of "hh:mm:ss" // // We start with a duration in number of seconds VAR Duration = SUM([Duration]) // 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
https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639#M389
Hi, Anonymous , you might want to tweak the measure as follows,
Chelsie Eiden's Duration (hh:mm) = VAR Duration = SUM ( [Duration] ) // 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 ) VAR Seconds = ROUNDUP ( MOD ( MOD ( Duration - ( Hours * 3600 ), 3600 ), 60 ), 0 ) RETURN Hours * 100 + Minutesthen format the measure as "0:00", voilà
2 Replies
- CNENFRNL
Community Champion
Hi, Anonymous , you might want to tweak the measure as follows,
Chelsie Eiden's Duration (hh:mm) = VAR Duration = SUM ( [Duration] ) // 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 ) VAR Seconds = ROUNDUP ( MOD ( MOD ( Duration - ( Hours * 3600 ), 3600 ), 60 ), 0 ) RETURN Hours * 100 + Minutesthen format the measure as "0:00", voilà
- Dodge365New Member
So awesome to find these kind of wonderful golden nuggets that completely saves the day. Thank you, thank you