let
源 = Folder.Files("---你的文件夹地址---"),
筛选 = Table.SelectRows(源, each Text.Contains([Name], "公司")),
自定义 = Table.AddColumn(筛选, "自定义", each
[a = Excel.Workbook([Content],true),
b = Table.SelectRows(a, each Text.Contains([Name], "部门")),
c = Table.SelectColumns(b, {"Name", "Data"}),
d = Table.ExpandTableColumn(c, "Data", Table.ColumnNames(Table.Combine(c[Data]))),
e = Table.RenameColumns(d, {"Name", "部门"})
][e]),
删除列 = Table.SelectColumns(自定义,{"Name", "自定义"}),
展开 = Table.ExpandTableColumn(删除列, "自定义", Table.ColumnNames(Table.Combine(删除列[自定义]))),
逆透视 = Table.UnpivotOtherColumns(展开, {"Name", "部门", "项目"}, "属性", "值"),
重命名 = Table.RenameColumns(逆透视,{{"Name", "公司"}, {"属性", "月份"},{"值", "数量"}}),
替换 = Table.ReplaceValue(重命名,".xlsx","",Replacer.ReplaceText,{"公司"})
in
替换 |