Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bourne2000
Helper V
Helper V

How to handle the call duration column?

Hi 

 

I have a column called Talk time. This is call centre data

 

bourne2000_0-1643621895554.png

 

When I tried to convert this column into duration, I am getting below

 

bourne2000_1-1643621934714.png

I want to calculate total talk time. When I calculated it was not coming properly.

 

Can anyone advise how to calculate correctly? Am I doing anything wrong?

 

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @bourne2000 ,

You can follow these steps to calcualte:

1. Change the data type of duration column to HH:MM:SS:

vluwangmsft_0-1644314605421.png

 

Then create new column:

SumTalkTime = 
VAR TotalSeconds =
    SUMX (
        'Table',
        HOUR ( 'Table'[Talktime] ) * 3600
            + MINUTE ( 'Table'[Talktime] ) * 60
            + SECOND ( 'Table'[Talktime] )
    )
VAR Days =
    TRUNC ( TotalSeconds / 3600 / 24 )
VAR Hors =
    TRUNC ( ( TotalSeconds - Days * 3600 * 24 ) / 3600 )
VAR Mins =
    TRUNC ( MOD ( TotalSeconds, 3600 ) / 60 )
VAR Secs =
    MOD ( TotalSeconds, 60 )
RETURN
    IF ( DAYS = 0, "", IF ( DAYS > 1, DAYS & "days ", Days & "day" ) )
        & IF ( Hors < 10, "0" & Hors, Hors ) & ":"
        & IF ( Mins < 10, "0" & Mins, Mins ) & ":"
        & IF ( Secs < 10, "0" & Secs, Secs )

Get:

vluwangmsft_1-1644314632892.png

Power bi not support duration type, I'd like to suggest you convert it as total second or other similar numeric value to calculate.
You can also take a look at below blog to know how to handle with duration in power bi:

Aggregating Duration/Time (Both Excel and DAX lack support for a true time duration data type making the display of duration in a format such as “HH:MM:SS” problematic. However, with some creative formulas, this problem can be solved.)

 

And similar question refer:

https://community.powerbi.com/t5/Desktop/duration-format/m-p/2180972 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @bourne2000 ,

You can follow these steps to calcualte:

1. Change the data type of duration column to HH:MM:SS:

vluwangmsft_0-1644314605421.png

 

Then create new column:

SumTalkTime = 
VAR TotalSeconds =
    SUMX (
        'Table',
        HOUR ( 'Table'[Talktime] ) * 3600
            + MINUTE ( 'Table'[Talktime] ) * 60
            + SECOND ( 'Table'[Talktime] )
    )
VAR Days =
    TRUNC ( TotalSeconds / 3600 / 24 )
VAR Hors =
    TRUNC ( ( TotalSeconds - Days * 3600 * 24 ) / 3600 )
VAR Mins =
    TRUNC ( MOD ( TotalSeconds, 3600 ) / 60 )
VAR Secs =
    MOD ( TotalSeconds, 60 )
RETURN
    IF ( DAYS = 0, "", IF ( DAYS > 1, DAYS & "days ", Days & "day" ) )
        & IF ( Hors < 10, "0" & Hors, Hors ) & ":"
        & IF ( Mins < 10, "0" & Mins, Mins ) & ":"
        & IF ( Secs < 10, "0" & Secs, Secs )

Get:

vluwangmsft_1-1644314632892.png

Power bi not support duration type, I'd like to suggest you convert it as total second or other similar numeric value to calculate.
You can also take a look at below blog to know how to handle with duration in power bi:

Aggregating Duration/Time (Both Excel and DAX lack support for a true time duration data type making the display of duration in a format such as “HH:MM:SS” problematic. However, with some creative formulas, this problem can be solved.)

 

And similar question refer:

https://community.powerbi.com/t5/Desktop/duration-format/m-p/2180972 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.