argmax
argmax, function
def autodiff process argmax(key: number, value: any): any
def autodiff process argmax(key: text, value: any): any
def autodiff process argmax(key: date, value: any): any
def autodiff process argmax(key: week, value: any): any
def autodiff process argmax(key: month, value: any): any
Returns the value associated with the maximum key. If multiple rows share the maximum key, one is chosen arbitrarily.
key: the ordering key, which can benumber,text,date,week, ormonth.value: the value returned from the row with the maximum key.
Examples
table T = with
[| as Product, as Price, as Weight |]
[| "Widget A", 100, 2.5 |]
[| "Widget B", 150, 1.8 |]
[| "Widget C", 75, 3.2 |]
show summary "Product analysis" with
argmax(T.Price, T.Product) as "Most Expensive"
argmax(T.Weight, T.Product) as "Heaviest"
Output:
| Most Expensive | Heaviest |
|---|---|
| Widget B | Widget C |
Remarks
When multiple rows share the same maximum key, the returned value is arbitrary. Reordering rows can change the result in tie cases.