argmin

argmin, process

def process argmin(a: number, b: 'b): 'b

Returns the b value associated with the minimum a value. The aggregator takes two arguments: a, the number used for ordering; and b, the paired value to be returned.

Example

table T = with
  [| as A, as B |]
  [| 2,   "c"   |]
  [| 0,   "a"   |]
  [| 1,   "b"   |]

V = argmin(T.A, T.B)

show scalar "T.B value at lowest T.A" with V

Remarks

When multiple rows share the same T.A value, argmin returns the corresponding T.B value from the first encountered row based on the table’s default order. Since argmin works as a sequential scan over the table, reordering the rows may lead to different outputs in cases of ties.

See also

User Contributed Notes
0 notes + add a note