简体   繁体   English

将 [Days, hh:mm.ss] 转换为 [hh:mm:ss]

[英]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.我有一个 Excel 文件,其中某个活动的持续时间以文本形式在表格列中。

6 Day(s), 03:57:03 6 天,03:57:03

I want to convert this, in PowerQuery Editor, to duration in hh:mm:ss.我想在 PowerQuery 编辑器中将其转换为 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-输出-

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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