4.15 Rank row-wise data by expression

 

Rank records of the following score table by the total of math, English and PE scores:

Class Name Math English PE
1 Tom 85 97 74
2 John 92 80 95
2 Joan 86 67 85
1 Rocky 95 95 75
2 Ham 92 75 53
1 Kate 83 99 50
1 Rose 95 62 81
2 Nomy 78 91 70
1 Neil 91 83 97
2 Jack 84 75 73
1 Joe 98 71 60

SPL script:

A
1 =T(“score.xlsx”)
2 =A1.(Math+English+PE)
3 =A1.derive(A2.rank@z(Math+English+PE):Rank)

A2 Get a sequence of totals of math, English and PE scores.
A3 Add a Rank field and calculate rank of the total of math, English and PE scores in the current row using A2’s expression.

Execution result:

Class Name Math English PE Rank
1 Tom 85 97 74 4
2 John 92 80 95 2
2 Joan 86 67 85 6
1 Rocky 95 95 75 3
2 Ham 92 75 53 11
1 Kate 83 99 50 8
1 Rose 95 62 81 6
2 Nomy 78 91 70 5
1 Neil 91 83 97 1
2 Jack 84 75 73 8
1 Joe 98 71 60 10