添加分类汇总小计行(Power Query)
问题:为数据添加小计行
let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
分组的行 = Table.Group(源, {"标题1"}, {"数据", each Table.InsertRows(_,Table.RowCount(_),{Record.FromList(List.Transform({0..2},(x)=> if x = 0 then "小计" else List.Transform(Table.ToColumns(_), each try List.Sum(_) otherwise "小计"){x}), Table.ColumnNames(源))})}),
删除的列 = Table.RemoveColumns(分组的行,{"标题1"}),
展开 = Table.ExpandTableColumn(删除的列, "数据", {"标题1", "标题2", "标题3"})
in
展开