Forum Discussion

Brazen_BI's avatar
Brazen_BI
Frequent Visitor
2 years ago
Solved

Convert Text (x Hours, xMinutes, xSeconds) to duration

Attempted unsuccessfully to convert text from column labeled "Handled Duration" into duration type with format "00:00:00". Purpose is to eventually use this column to calcuate total and average handle time durations. Have tried simply changing format (which returns expressions:error:we couldn't parse the Duration literal). I'm aware of the duration.fromtext function, though every iteration i've tried has failed. Can someone please assist?

  • Hi, Brazen_BI 

     

    =Time.From(
    Text.Combine(
    List.Transform(
    Text.Split([Handled Duration],", "),
    each Text.BeforeDelimiter(_," ")),
    ":")
    )

    or

    #time(
    Number.From(Text.BeforeDelimiter([Handled Duration]," Hours")),
    Number.From(Text.BetweenDelimiters([Handled Duration],"Hours, "," Min")),
    Number.From(Text.BetweenDelimiters([Handled Duration],"Minutes, "," Sec")))

     

    Stéphane 

2 Replies

  • Hi, Brazen_BI 

     

    =Time.From(
    Text.Combine(
    List.Transform(
    Text.Split([Handled Duration],", "),
    each Text.BeforeDelimiter(_," ")),
    ":")
    )

    or

    #time(
    Number.From(Text.BeforeDelimiter([Handled Duration]," Hours")),
    Number.From(Text.BetweenDelimiters([Handled Duration],"Hours, "," Min")),
    Number.From(Text.BetweenDelimiters([Handled Duration],"Minutes, "," Sec")))

     

    Stéphane 

    • Brazen_BI's avatar
      Brazen_BI
      Frequent Visitor

      Thanks. I combined this solution with a measure to calculate average duration time to get the final visual I needed: 

      Average Handle Time Duration = FORMAT(AVERAGE('Table'[Column]),"HH:MM: SS")