cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mcolb88
Advisor

Re: How do display duration properly?

As a calculated column:

 

VAR Minutes = ROUNDDOWN([CallDurationSeconds]/60,0)

VAR Seconds = ROUNDUP(([CallDurationSeconds] - Minutes*60), 0)

RETURN IF([CallDurationSeconds]>0, CONCATENATE(CONCATENATE(FORMAT(Minutes, "##0"), ":"), RIGHT(CONCATENATE("0", FORMAT(Seconds, "##")),2)), BLANK())

 

And as a formatted measure using the numeric equivalent.

 

Avg Call Duration:= AVERAGEX('Interview Call', [CallDurationSeconds]/60)

 

Avg Call Duration (min):=

VAR Minutes = ROUNDDOWN([Avg Call Duration],0)

VAR Seconds = ROUNDUP(([Avg Call Duration] - Minutes)*60, 0)

RETURN CONCATENATE(CONCATENATE(FORMAT(Minutes, "##0"), ":"), RIGHT(CONCATENATE("0", FORMAT(Seconds, "#0")),2))

 

Could add hours to this as well, but that's pretty far out of range for my application.

 

Hope this helps

luigidlt Visitor
Visitor

Re: How do display duration properly?

Is there any way to make it work for durations lower than 3600. Otherwise I get 12hr in all durations.

 

Thanks

thehy Frequent Visitor
Frequent Visitor

Re: How do display duration properly?

Hi,

 

There is a much easier way to do this without DAX or code; with the latest version of PowerBI Desktop at least.

 

1. Convert the column(s) to 'Duration'

2. This should give you the duration in the format dd.hh:mm:ss.ms

3. Use the edit query 'Extract' -> 'Between delimiters'

4. Enter '.' as the start delimiter and ':' as the end delimiter

5. For the start, scan 'From the end of the input' and skip 2 delimiters

6. For the end, scan 'From the start delimiter, toward the end of the input' and skip 1 delimiter

 

And that should do it. It works for less that 3600 secs as I have durations less than an hour and more than a day.

 

 

Extract Duration Delimiter (Sample).JPGExtract Duration Delimiter.jpg

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors