The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 |
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks for your post. Over the weekend I found a formula that end up working.
@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) )
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
28 | |
13 | |
12 | |
12 | |
6 |