Forum Discussion

pratapchava's avatar
pratapchava
Regular Visitor
6 years ago
Solved

Convert time hour to integer/number

Hi ,

I have a column WorkedTime  as Text. For example 08:55, trying to convert 8.91 hours.

and some of the columns has value morethan 24 hours Eg: 26:55, 31:40.

 

How can I convert these type of time values into number or am I able to apply filter in advance editor for these values?

 

getting data from SQL database in import mode.

 

Appreciate any help.

Thanks

  • Hi pratapchava ,

    For your requirement, I think you need to split the WorkedTime column firstly. You could follow my steps to have a try.

    • Split column by colon

    • Add a new column 

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjKzMjVVitWJVjI2tDIxALMMLMBisQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [WorkedTime = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkedTime", type text}}),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "WorkedTime", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"WorkedTime.1", "WorkedTime.2"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"WorkedTime.1", Int64.Type}, {"WorkedTime.2", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [WorkedTime.1] + [WorkedTime.2]/60)
    in
        #"Added Custom"

    Best Regards,

    Xue Ding

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

     

2 Replies

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi pratapchava ,

    For your requirement, I think you need to split the WorkedTime column firstly. You could follow my steps to have a try.

    • Split column by colon

    • Add a new column 

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjKzMjVVitWJVjI2tDIxALMMLMBisQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [WorkedTime = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkedTime", type text}}),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "WorkedTime", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"WorkedTime.1", "WorkedTime.2"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"WorkedTime.1", Int64.Type}, {"WorkedTime.2", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [WorkedTime.1] + [WorkedTime.2]/60)
    in
        #"Added Custom"

    Best Regards,

    Xue Ding

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