Forum Discussion

Tevon713's avatar
Tevon713
Icon for Helper V rankHelper V
3 years ago
Solved

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 return...
  • Anonymous's avatar
    Anonymous
    3 years ago

    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:

     

    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