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 restrictions as arg1.

Examples

Example 1: Find highest rated items

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]
}
}
}

If we want to find highest rated service stations, we can just use MAX:

MAX(data.local_service_ratings.cheapest, data.local_service_ratings.nearest)

This returns the following:

6

Example 2: Using arrays as arguments

MAX can also take arrays as arguments, as shown below:

MAX(data.local_service_ratings.cheapest, data.local_service_ratings.nearest, data.local_service_ratings.regional)

This returns the following:

9