sandy666
05-11-2020, 04:21 AM
Sort ascending values by minimum value from each group
JOBAMOUNTJOBAMOUNT
A
-120A
-120
A
120A
-35
A
-9A
-9
A
-35A
120
B
30F
-110
B
-30F
-90
C
40F
50
D
-30D
-35
D
-35D
-30
D
60D
60
E
-34E
-34
E
40E
40
F
-110B
-30
F
50B
30
F
-90C
40
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
JOBAMOUNTJOBAMOUNT
A
-120A
-120
A
120A
-35
A
-9A
-9
A
-35A
120
B
30F
-110
B
-30F
-90
C
40F
50
D
-30D
-35
D
-35D
-30
D
60D
60
E
-34E
-34
E
40E
40
F
-110B
-30
F
50B
30
F
-90C
40
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