-
PQ - Number grouped rows
Number grouped rows
| source |
|
|
|
result |
|
|
|
| Group |
Category |
Sales |
|
Group |
Category |
Sales |
Index |
| Food |
Breakfast |
99,562.64 |
|
Alcohol |
Wine |
217492.74 |
1 |
| Food |
Soups/Salads |
113,642.33 |
|
Alcohol |
Draft Beer |
132882.83 |
2 |
| Food |
Sandwiches |
217,510.36 |
|
Alcohol |
Liquor |
50939.94 |
3 |
| Food |
Entrees |
290,278.36 |
|
Alcohol |
Canned Beer |
49996.55 |
4 |
| Food |
Non Alc Beverage |
93,580.81 |
|
Alcohol |
Bottled Beer |
29043.99 |
5 |
| Food |
Appetizers |
98,191.52 |
|
Alcohol |
Coolers/Ciders |
22628.14 |
6 |
| Alcohol |
Draft Beer |
132,882.83 |
|
Alcohol |
Liquor Modifiers |
9.3 |
7 |
| Food |
Burgers |
138,000.37 |
|
Food |
Entrees |
290278.36 |
1 |
| Food |
Desserts |
16,039.30 |
|
Food |
Sandwiches |
217510.36 |
2 |
| Alcohol |
Wine |
217,492.74 |
|
Food |
Burgers |
138000.37 |
3 |
| Alcohol |
Bottled Beer |
29,043.99 |
|
Food |
Soups/Salads |
113642.33 |
4 |
| Alcohol |
Liquor |
50,939.94 |
|
Food |
Breakfast |
99562.64 |
5 |
| Alcohol |
Coolers/Ciders |
22,628.14 |
|
Food |
Appetizers |
98191.52 |
6 |
| Alcohol |
Canned Beer |
49,996.55 |
|
Food |
Non Alc Beverage |
93580.81 |
7 |
| Alcohol |
Liquor Modifiers |
9.30 |
|
Food |
Desserts |
16039.3 |
8 |
| Food |
Cakes |
234.55 |
|
Food |
Cakes |
234.55 |
9 |
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
Type = Table.TransformColumnTypes(Source,{{"Group", type text}, {"Category", type text}, {"Sales", type number}}),
Sort = Table.Sort(Type,{{"Group", Order.Ascending}, {"Sales", Order.Descending}}),
Group = Table.Group(Sort, {"Group"}, {{"Data", each _, type table}}),
InnerIndex = Table.AddColumn(Group, "Partitioned", each Table.AddIndexColumn([Data], "Index", 1, 1)),
RC = Table.RemoveColumns(InnerIndex,{"Data"}),
Expand = Table.ExpandTableColumn(RC, "Partitioned", {"Category", "Sales", "Index"}, {"Category", "Sales", "Index"})
in
Expand