Source |
|
|
|
|
|
Result |
|
|
|
|
|
First |
Second |
Third |
Fourth |
Fifth |
|
Label |
First |
Second |
Third |
Fourth |
Fifth |
69 |
76 |
37 |
40 |
10 |
|
Data |
69 |
76 |
37 |
40 |
10 |
98 |
51 |
41 |
59 |
82 |
|
Data |
98 |
51 |
41 |
59 |
82 |
86 |
90 |
69 |
72 |
87 |
|
Data |
86 |
90 |
69 |
72 |
87 |
33 |
50 |
92 |
27 |
45 |
|
Data |
33 |
50 |
92 |
27 |
45 |
15 |
72 |
61 |
41 |
93 |
|
Data |
15 |
72 |
61 |
41 |
93 |
80 |
46 |
73 |
93 |
51 |
|
Data |
80 |
46 |
73 |
93 |
51 |
1 |
89 |
18 |
64 |
54 |
|
Data |
1 |
89 |
18 |
64 |
54 |
69 |
42 |
89 |
75 |
64 |
|
Data |
69 |
42 |
89 |
75 |
64 |
|
|
|
|
|
|
Total |
451 |
516 |
480 |
471 |
486 |
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Label = Table.AddColumn(Source, "Label", each "Data"),
Move = Table.ReorderColumns(Label,{"Label", "First", "Second", "Third", "Fourth", "Fifth"}),
AddTotal = Table.AddColumn(Move, "Custom", each "Total"),
Group = Table.Group(AddTotal, {"Custom"}, {{"First", each List.Sum([First]), type number}, {"Second", each List.Sum([Second]), type number}, {"Third", each List.Sum([Third]), type number}, {"Fourth", each List.Sum([Fourth]), type number}, {"Fifth", each List.Sum([Fifth]), type number}}),
Ren = Table.RenameColumns(Group,{{"Custom", "Label"}}),
Append = Table.Combine({Move, Ren})
in
Append
Bookmarks