10.14 Rank in group

 

Here below is a data table:

imagepng

To calculate the ranking of students in the class, and fill in the results in corresponding cell of column E, enter in cell E1:

A
1 =E(‘B1:D12’).derive(:RankInClass)
2 =A1.group(Class).run(a=~.ranks@z(Maths),~.run(RankInClass=a(#)))
3 return A1.new(RankInClass)

A1: Convert the data to a two-dimensional table sequence, and add one column RankInClass.
A2: Group by class, calculate ranking within each group, and assign the value to RankInClass.
A3: Return RankInClass.

imagepng