Aggregate FunctionsArg
arg_max
Returns both the maximum value and the corresponding return expression from the row where the first expression is maximum.
Syntax
arg_max(maximize, return_expr)Parameters
Prop
Type
Returns: any
Examples
Example 1
datatable(clan:string, warrior:string, voyages:long)[
"Lothbrok", "Ragnar", 42,
"Lothbrok", "Bjorn", 31,
"Fairhair", "Harald", 25,
"Lothbrok", "Ivar", 35
]
| summarize arg_max(voyages, warrior) by clan| clan (string) | voyages (dynamic) | warrior (dynamic) |
|---|---|---|
| Fairhair | 25 | "Harald" |
| Lothbrok | 42 | "Ragnar" |
Example 2
datatable(region:string, raid:string, loot:long)[
"England", "Lindisfarne", 500,
"England", "York", 1200,
"Francia", "Paris", 7000,
"Francia", "Rouen", 3000
]
| summarize (best_loot, best_raid) = arg_max(loot, raid) by region| region (string) | best_loot (dynamic) | best_raid (dynamic) |
|---|---|---|
| England | 1200 | "York" |
| Francia | 7000 | "Paris" |