- let
- Source = Excel.CurrentWorkbook(){[Name="a"]}[Content],
- #"Changed Type" = Table.TransformColumnTypes(Source,{{"月份", Int64.Type}, {"凭证字号", type text}, {"摘要", type any}, {"科目代码", type text}, {"一级科目", type text}, {"方向", type text}, {"借方", type number}, {"贷方", type number}, {"对应科目", type text}}),
- #"Grouped Rows" = Table.TransformColumns(Table.Group(#"Changed Type", {"月份", "凭证字号", "摘要", "一级科目"}, {{"a", each _}}),{"a",(t)=> Record.FromList(Table.ToColumns(Table.SelectColumns(t,{"借方","贷方","对应科目"})),{"借方","贷方","对应科目"} )}),
- #"Expanded a" = Table.TransformColumns(Table.ExpandRecordColumn(#"Grouped Rows", "a", {"借方", "贷方", "对应科目"}, {"借方", "贷方", "对应科目"}),{{"借方",each List.Sum(_)},{"贷方",each List.Sum(_)},{"对应科目",each Text.Combine(List.Distinct(_),",")}})
- in
- #"Expanded a"
复制代码
|