简体   繁体   中英

Convert [Days, hh:mm.ss] to [hh:mm:ss]

I have an Excel file with the duration time of a certain activity in text form, in a table column.

6 Day(s), 03:57:03

I want to convert this, in PowerQuery Editor, to duration in hh:mm:ss. How can I do this?

If you have all data in given format, you can use this below Advanced Editor code for your purpose-

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlNwSazUKNbUUTAwtjI1tzIwVoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [text_column = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"text_column", type text}}),
    
    // New steps starts here
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "text_column", Splitter.SplitTextByDelimiter(" Day(s), ", QuoteStyle.Csv), {"text_column.1", "text_column.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "text_column.2", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"text_column.2.1", "text_column.2.2", "text_column.2.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"text_column.1", Int64.Type}, {"text_column.2.1", Int64.Type}, {"text_column.2.2", Int64.Type}, {"text_column.2.3", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"text_column.1", "day"}, {"text_column.2.1", "hour"}, {"text_column.2.2", "min"}, {"text_column.2.3", "sec"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each Text.From([day]*24+[hour]) & ":" &Text.From([min]) & ":" &Text.From([sec]))
in
    #"Added Custom"

Input-

在此处输入图像描述

Output-

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM