nthmax

nthmax, function

def process nthmax(value: number; nth: number): number

Returns the nth largest value within a group, with nth starting at 1.

Examples

table T = with
  [| as Value |]
  [| 2 |]
  [| 0 |]
  [| 1 |]
  [| 4 |]
  [| 3 |]

v = nthmax(T.Value; 2)

show table "Nth max" with
  v as "Second"

This produces the following table:

Second
3

Remarks

If fewer than nth values exist, the smallest value is returned. Empty groups return the default value.

User Contributed Notes
0 notes + add a note