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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Tevon713
Helper IV
Helper IV

Duration Conversion and Calculation

I have incident time stamp column, attempted to convert to duration. It giving the "Expression.Error: We couldn't parse the Duration literal."

 

Searched and found in the community, it now returning "null" for those not having days in custom column. How to correctly format and then take average of this column to display in d:h:m:s ?

 

https://community.powerbi.com/t5/Desktop/Convert-the-column-into-duration-Throwing-an-error/td-p/231...

 

Tevon713_0-1666708055415.png

 

Tevon713_1-1666708102425.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Tevon713 ,

Here are the steps you can follow:

1. Create calculated column.

Convert Time to Second:

seconds =
var _day=VALUE(left('Table'[Incident Duratio:create-resolve],2))
var _hour=VALUE(MID('Table'[Incident Duratio:create-resolve],4,2))
var _minute=VALUE(MID('Table'[Incident Duratio:create-resolve],7,2))
var _second=VALUE(RIGHT('Table'[Incident Duratio:create-resolve],2))
return
_day * 24 * 60* 60
+
_hour * 60 * 60
+
_minute * 60
+
_second

average time:

Duration Average =
RIGHT ( "0" & INT ( AVERAGEA ( 'Table'[seconds] ) / ( 24 * 60 * 60 ) ), 2 ) & ":"
    & RIGHT (
        "0"
            & INT (
                (
                    AVERAGEA ( 'Table'[seconds] )
                        - INT ( AVERAGEA ( 'Table'[seconds] ) / ( 24 * 60 * 60 ) ) * ( 24 * 60 * 60 )
                ) / 3600
            ),
        2
    ) & ":"
    & RIGHT (
        "0"
            & INT (
                (
                    AVERAGEA ( 'Table'[seconds] )
                        - INT ( AVERAGEA ( 'Table'[seconds] ) / 3600 ) * 3600
                ) / 60
            ),
        2
    ) & ":"
    & RIGHT (
        "0"
            & (
                AVERAGEA ( 'Table'[seconds] )
                    - INT ( AVERAGEA ( 'Table'[seconds] ) / 60 ) * 60
            ),
        2
    )

2. Result:

vyangliumsft_0-1666754105453.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Tevon713 ,

Here are the steps you can follow:

1. Create calculated column.

Convert Time to Second:

seconds =
var _day=VALUE(left('Table'[Incident Duratio:create-resolve],2))
var _hour=VALUE(MID('Table'[Incident Duratio:create-resolve],4,2))
var _minute=VALUE(MID('Table'[Incident Duratio:create-resolve],7,2))
var _second=VALUE(RIGHT('Table'[Incident Duratio:create-resolve],2))
return
_day * 24 * 60* 60
+
_hour * 60 * 60
+
_minute * 60
+
_second

average time:

Duration Average =
RIGHT ( "0" & INT ( AVERAGEA ( 'Table'[seconds] ) / ( 24 * 60 * 60 ) ), 2 ) & ":"
    & RIGHT (
        "0"
            & INT (
                (
                    AVERAGEA ( 'Table'[seconds] )
                        - INT ( AVERAGEA ( 'Table'[seconds] ) / ( 24 * 60 * 60 ) ) * ( 24 * 60 * 60 )
                ) / 3600
            ),
        2
    ) & ":"
    & RIGHT (
        "0"
            & INT (
                (
                    AVERAGEA ( 'Table'[seconds] )
                        - INT ( AVERAGEA ( 'Table'[seconds] ) / 3600 ) * 3600
                ) / 60
            ),
        2
    ) & ":"
    & RIGHT (
        "0"
            & (
                AVERAGEA ( 'Table'[seconds] )
                    - INT ( AVERAGEA ( 'Table'[seconds] ) / 60 ) * 60
            ),
        2
    )

2. Result:

vyangliumsft_0-1666754105453.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thank you @Anonymous.

 

I'm getting this error, tried converting column various format. Attached link to pbix here.

Tevon713_0-1666798834278.png

 

Another quick question: If I wanted to calculate the average of all numbers that belongs to a certain category. I'm thinking something along the line of the follow...


Average Number of Category=
Calculate('Table'[Duration Average],Filter(Table, 'Table'[ColumnName]="XYZ"))

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors