Forum Discussion
espensun
Oct 19, 2024Copper Contributor
Sorting a table with groups of people (no VBA)
Hi, I have a table with groups of people in a team. The individual team can vary from 3 to 4 persons. The table list the group and their group score/result (se attached image). How can I sort the t...
- Oct 19, 2024
If you already have GROUPBY:
=LET( grouped, GROUPBY( Table[Group], Table[Res.], SUM,, 0 ), filled_res, XLOOKUP( Table[Group], CHOOSECOLS( grouped, 1 ), CHOOSECOLS( grouped, 2) ), sorted, SORTBY( Table, filled_res, 1, SEQUENCE( ROWS( Table ) ), 1 ), IF( ISBLANK( sorted ), "", sorted ) )
peiyezhu
Oct 20, 2024Bronze Contributor
sql:
select * from OriginalData;
select f01,f02,f03 from (select rowid old_rowid,*,max(f03) over(partition by f02) ord from OriginalData) order by ord,old_rowid;
f01 | f02 | f03 |
bbb | 1 | |
aaa | 1 | |
dddd | 1 | |
cccc | 1 | 49 |
eee | 2 | |
kkk | 2 | |
hhhh | 2 | 48 |
zzzz | 3 | |
yyyy | 3 | |
www | 3 | |
xxxx | 3 | 55 |
f01 | f02 | f03 |
eee | 2 | |
kkk | 2 | |
hhhh | 2 | 48 |
bbb | 1 | |
aaa | 1 | |
dddd | 1 | |
cccc | 1 | 49 |
zzzz | 3 | |
yyyy | 3 | |
www | 3 | |
xxxx | 3 | 55 |