Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi everyone,
I have a measure which returns the seconds:
Solved! Go to Solution.
@Anonymous Oh, so negative numbers are wrong. It was never tested with negative numbers. This is what I would do. One, that might be able to be fixed by using TRUNC instead of INT. But, the sure-fire way is this:
Hours and seconds =
Var __Sign = SIGN([ME_Seconds])
var Seconds=ABS([ME_Seconds])
var Hours =INT(Seconds/3600)
var Minutes = INT(MOD( Seconds - ( Hours * 3600 ), 3600 ) / 60 )
return
(Hours* 100 + Minutes) * __Sign
@Anonymous I've been seeing this come up lately where there are issues with what is essentially Chelsie Eiden's Duration. Chelsie Eiden's Duration - Microsoft Power BI Community. So, I put together a quick check with seconds running from 0 to 10,000 and cannot replicate the behavior. Everything looks correct in terms of the number of hours, minutes and seconds in the check file so would be interested if you see something different when you open it. File is attached below sig.
hey @Greg_Deckler , thanks for your suggestion. Unfortunately, it doesn't work. The minutes and seconds still returns answer >60, so for example -2:73:75 when the correct result should be -2:33
@Anonymous Oh, so negative numbers are wrong. It was never tested with negative numbers. This is what I would do. One, that might be able to be fixed by using TRUNC instead of INT. But, the sure-fire way is this:
Hours and seconds =
Var __Sign = SIGN([ME_Seconds])
var Seconds=ABS([ME_Seconds])
var Hours =INT(Seconds/3600)
var Minutes = INT(MOD( Seconds - ( Hours * 3600 ), 3600 ) / 60 )
return
(Hours* 100 + Minutes) * __Sign
Thank you so much @Greg_Deckler ! I have been working on it for a while, and I couldn't find the solution. This works great!
@Anonymous I'm just glad I finally figured out where people were having problems with that code. @konstantinos and I created that code a long time ago and it has pretty much stood the test of time. I will definitely update the Chelsie Eiden's Duration quick measure in my external tool, Microsoft Hates Greg's Quick Measures for the next release! Thanks for your part in improving this code!!
@Greg_Deckler that's great to hear! I'm pleased that I was able to help in this way!
Thanks @amitchandak ,
I changed the measure to:
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.