cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pratapchava Visitor
Visitor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Convert time hour to integer/number

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

1.PNG2.PNG

  • Add a new column 

3.PNG4.PNG

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.

 

View solution in original post

2 REPLIES 2
JirkaZ Regular Visitor
Regular Visitor

Re: Convert time hour to integer/number

@pratapchava In PowerQuery you can use Duration.FromText

https://docs.microsoft.com/en-us/powerquery-m/duration-fromtext

 

 

Community Support Team
Community Support Team

Re: Convert time hour to integer/number

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

1.PNG2.PNG

  • Add a new column 

3.PNG4.PNG

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.

 

View solution in original post

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (4,194)