MAX

MAX returns the largest value in a numeric dataset. It also takes an arbitrary number of additional arguments.

Function category: Statistical

Syntax

MAX(arg1, [arg2...])

Arguments

Description

arg1

Number, string or an array of numbers or strings (or anything that can be coerced into being a number)

arg2

Optional. Same requirements as arg1.

Examples

Let's say we're given a response with some service station information that looks like this:

{
"data": {
"local_service_ratings": {
"cheapest": 4,
"nearest": 6,
"regional": [
4,
5,
6,
8,
9
]
}
}
}

Example 1: Find highest rated items

If we want to find highest rated service stations, use the following function.

# Find highest rated
MAX(data.local_service_ratings.cheapest,
data.local_service_ratings.nearest
)
# Returns 6

Example 2: Using arrays as arguments

MAX can also take arrays as arguments, as shown in the following function.

# Find the largest regional service station
MAX(data.local_service_ratings.cheapest,
data.local_service_ratings.nearest,
data.local_service_ratings.regional
)
# Returns 9