我有将近100多个excel文件,每个文件有6个标签或更多标签。每个选项卡的格式相同。我需要使用Power Query合并所有文件中的一个表(“需要制表符”),但是在合并之前,我需要对每个表进行转置。
这是我尝试过的内容(最后一条“反转”行已从How to transpose multiple .csv files and combine in Excel power query?进行了修改):
let
Source = Folder.Files("Directory"),
#"Added Custom" = Table.AddColumn(Source, "Custom", each Excel.Workbook([Content],true)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom", "Name"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Name", "Data", "Item", "Kind", "Hidden"}, {"Name.1", "Data", "Item", "Kind", "Hidden"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each ([Item] = "Tab Required")),
#"Removed Other Columns1" = Table.SelectColumns(#"Filtered Rows",{"Data", "Name"}),
#"Invert" = Table.TransformColumns(#"Removed Other Columns1", {{"Data", each Table.Transpose(xlsx.Document(_))}}),
MaxColumns = List.Max(List.Transform(#"Invert"[Data], each Table.ColumnCount(_))),
#"Expanded Content" = Table.ExpandTableColumn(#"Invert", "Data", List.Transform({1..MaxColumns}, each "Column" & Number.ToText(_)))
in
#"Expanded Content"
但是我遇到了以下错误消息:
表达错误:无法识别名称“ xlsx.Document”。确保拼写正确。
有人可以帮我吗?
答案 0 :(得分:0)
#"Invert" = Table.TransformColumns(#"Removed Other Columns1", {{"Data", each Table.Transpose(_)}})
或者如果您想要列标题
#"Invert" = Table.TransformColumns(#"Removed Other Columns1", {{"Data", each Table.Transpose(Table.DemoteHeaders(_))}}),