求大神帮转下考情表格式
求大神帮从把考勤原始表标识数据调整生成新的格式用函数会比较复杂,改用PQ做了一个。let
源 = Excel.CurrentWorkbook(){},
删除的顶端行 = Table.Skip(源,1),
提升的标题 = Table.PromoteHeaders(删除的顶端行, ),
逆透视的其他列 = Table.UnpivotOtherColumns(提升的标题, {"姓名"}, "属性", "值"),
按分隔符拆分列 = Table.SplitColumn(Table.TransformColumnTypes(逆透视的其他列, {{"值", type text}}, "zh-CN"), "值", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"值.1", "值.2", "值.3", "值.4"}),
更改的类型1 = Table.TransformColumnTypes(按分隔符拆分列,{{"值.1", type time}, {"值.2", type time}, {"值.3", type time}, {"值.4", type time}, {"属性", type datetime}}),
逆透视的其他列1 = Table.UnpivotOtherColumns(更改的类型1, {"姓名", "属性"}, "属性.1", "值"),
删除的列 = Table.RemoveColumns(逆透视的其他列1,{"属性.1"}),
更改的类型 = Table.TransformColumnTypes(删除的列,{{"属性", type date}}),
合并的列 = Table.CombineColumns(Table.TransformColumnTypes(更改的类型, {{"属性", type text}, {"值", type text}}, "zh-CN"),{"属性", "值"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"时间")
in
合并的列
同PQ
let
源 = Excel.CurrentWorkbook(){},
逆透视的其他列 = Table.UnpivotOtherColumns(源, {"姓名"}, "属性", "值"),
按分隔符拆分列 = Table.ExpandListColumn(Table.TransformColumns(逆透视的其他列, {{"值", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.None), let itemType = (type nullable text) meta in type {itemType}}}), "值"),
合并的列 = Table.CombineColumns(Table.TransformColumnTypes(按分隔符拆分列, {{"值", type text}}, "zh-CN"),{"属性", "值"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"打卡时间"),
更改的类型1 = Table.TransformColumnTypes(合并的列,{{"打卡时间", type datetime}})
in
更改的类型1 非常感谢帮忙!请问代码怎么复制和使用的,之前没用过PQ,感谢指导 let
源 = Excel.Workbook(File.Contents("D:\下载\考勤表调整格式.xlsx"), null, true),
表1_Table = 源{},
逆透视的其他列 = Table.UnpivotOtherColumns(表1_Table, {"姓名"}, "属性", "值"),
按分隔符拆分列 = Table.ExpandListColumn(Table.TransformColumns(逆透视的其他列, {{"值", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta in type {itemType}}}), "值"),
更改的类型 = Table.TransformColumnTypes(按分隔符拆分列,{{"值", type time}, {"姓名", type text}, {"属性", type date}}),
重命名的列 = Table.RenameColumns(更改的类型,{{"属性", "日期"}, {"值", "时间"}})
in
重命名的列
页:
[1]