Sort ascending values by minimum value from each group
JOB |
AMOUNT |
|
JOB |
AMOUNT |
A |
-120 |
|
A |
-120 |
A |
120 |
|
A |
-35 |
A |
-9 |
|
A |
-9 |
A |
-35 |
|
A |
120 |
B |
30 |
|
F |
-110 |
B |
-30 |
|
F |
-90 |
C |
40 |
|
F |
50 |
D |
-30 |
|
D |
-35 |
D |
-35 |
|
D |
-30 |
D |
60 |
|
D |
60 |
E |
-34 |
|
E |
-34 |
E |
40 |
|
E |
40 |
F |
-110 |
|
B |
-30 |
F |
50 |
|
B |
30 |
F |
-90 |
|
C |
40 |
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Group = Table.Group(Source, {"JOB"}, {{"Count", each _, type table}}),
ListMin = Table.AddColumn(Group, "Custom", each List.Min([Count][AMOUNT])),
Expand = Table.ExpandTableColumn(ListMin, "Count", {"AMOUNT"}, {"AMOUNT"}),
SortAsc = Table.Sort(Expand,{{"Custom", Order.Ascending}, {"AMOUNT", Order.Ascending}}),
RC = Table.RemoveColumns(SortAsc,{"Custom"})
in
RC
Bookmarks