let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
向下填充 = Table.FillDown(源,{"班级"}),
分组的行 = Table.Group(向下填充, {"班级"}, {"计数", each _}),
表格深化 = Table.TransformColumns(分组的行,{"计数",each Table.FromRows(List.Split(List.RemoveItems(Text.Split(Text.Combine( List.Transform(Text.Split(Text.Combine([课程得分]," ")," "),each try if Number.From(Text.At(_,0)) is number and Text.End(_,1) is text then Text.Insert(_,List.Max(Text.PositionOfAny(_,{"0".."9"},2))+1," ") else _ otherwise _)," ")," "),{""," ",null}),2),{"科目","成绩"})}),
展开 = Table.ExpandTableColumn(表格深化, "计数", {"科目", "成绩"}, {"科目", "成绩"}),
已透视列 = Table.Pivot(展开, List.Distinct(展开[科目]), "科目", "成绩", each Number.From(_{0}))
in
已透视列 |