MAXBY
Returns the object with the maximum value of a specified property.
Syntax
MAXBY(array, property)
Arguments
array
: The array or collection to iterate over.property
: The property name to compare values by.
Example
MAXBY(A1:A5, "value") → Returns the object in the range A1:A5 with the maximum value for the "value" property.
MAXBY([{value: 10, id: 1}, {value: 5, id: 2}, {value: 15, id: 3}], "value") → Returns {value: 15, id: 3}.
Usage Notes:
- If multiple objects have the same maximum value, the first one encountered is returned.
- If the array is empty, or no object has the specified property, the function may return
null
orundefined
(implementation dependent). - The function assumes that the property values are comparable (e.g., numbers or strings).