|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
指标加一个索引,透视后排序
let
源 = Excel.Workbook(File.Contents("***文件地址***\汇总机器指标表.xlsx"), null, true),
筛选 = Table.SelectRows(源, each Text.Contains([Name], "月") and [Kind] = "Sheet"),
自定义 = Table.AddColumn(筛选, "自定义", each
[a = Table.Skip([Data], 3),
b = Table.AddColumn(a, "a", each if Text.Contains([Column1], "机器") then [Column1] else null),
c = Table.FillDown(b, {"a"}),
d = Table.SelectRows(c, each [Column2]<>null),
e = Table.Group(d, "a", {"b", each Table.AddIndexColumn(Table.SelectColumns(_, {"Column1", "Column2"}), "no", 1)}),
f = Table.ExpandTableColumn(e, "b", {"Column1", "Column2", "no"})
][f]),
删除列 = Table.SelectColumns(自定义,{"自定义", "Name"}),
展开 = Table.ExpandTableColumn(删除列, "自定义", {"a", "Column1", "Column2", "no"}),
已透视列 = Table.Pivot(展开, List.Distinct(展开[Name]), "Name", "Column2", List.Sum),
排序的行 = Table.Sort(已透视列,{{"a", Order.Ascending}, {"no", Order.Ascending}}),
删除的列 = Table.RemoveColumns(排序的行,{"no"}),
重命名 = Table.RenameColumns(删除的列,{{"a", "机器"}, {"Column1", "指标"}})
in
重命名 |
|