cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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 Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)