MAX function

Synopsis
This function returns the maximum value found in an array. If the array is empty, the function returns an error.
Variations
MAX(SourceArray)
Returns the maximum of all elements of the source array.
Parameters
SourceArray

Specifies the array to work with.

Supported types: Numeric array; Boolean array.
Returns
Returned types: Numeric.
Examples
1.

The following example returns the maximum value in the array, 10.

MAX([5, 10, 0, -10, 0])
2.

To avoid an error when you pass an empty array to this function, you could use the following expression. Note the example above is encapsulated in the following IF statement.

IF(COUNT([5, 10, 0, -10, 0]) > 0, MAX([5, 10, 0, -10, 0]) , -1)
MAX(SourceArray, StartIndex, Count)
Returns the maximum of all the elements of a subset of the source array.
Parameters
SourceArray

Specifies the array to work with.

Supported types: Numeric array; Boolean array.
StartIndex

Specifies the beginning of the subset of the source array.

Supported types: Numeric.
Count

Specifies the number of elements to include in the subset of the source array.

Supported types: Numeric.
Returns
Returned types: Numeric.
Examples
1.

The following example calculates the maximum value in , the specified subset of the array. The function returns 5.

MAX([5, -10, 0, 10, 0], 1, 3)
2.

To avoid an error when you pass an empty array to this function, you could use the following expression. Note the example above is encapsulated in the following IF statement.

IF(COUNT([5, -10, 0, 10, 0]) > 0, MAX([5, -10, 0, 10, 0], 1, 3) , -1)
MAX(SourceArray, Expression)
Returns the maximum of all elements of the source array after performing an expression on each element.
Parameters
SourceArray

Specifies the array to work with.

Supported types: Numeric array; Boolean array; String array; Point array; Object array.
Expression

Specifies the expression to apply to each element of the source array.

Supported types: Numeric.
Returns
Returned types: Numeric.
Examples
1.

The following example calculates the maximum value after squaring each element. The function returns 16.

MAX([-1, -4, -1, 0, -1, -4], Item*Item)
2.

To avoid an error when you pass an empty array to this function, you could use the following expression. Note the example above is encapsulated in the following IF statement.

IF(COUNT([-1, -4, -1, 0, -1, -4]) > 0, MAX([-1, -4, -1, 0, -1, -4], Item* Item) , -1)
MAX(SourceArray, StartIndex, Count, Expression)
Returns the maximum of all the elements of a subset of the source array after performing an expression on each element.
Parameters
SourceArray

Specifies the array to work with.

Supported types: Numeric array; Boolean array; String array; Point array; Object array.
StartIndex

Specifies the beginning of the subset of the source array.

Supported types: Numeric.
Count

Specifies the number of elements to include in the subset of the source array.

Supported types: Numeric.
Expression

Specifies the expression to apply to each element of the source array.

Supported types: Numeric.
Returns
Returned types: Numeric.
Examples
1.

The following example returns the maximum value found in [-1, 0, -1, -4] after squaring each element. The function returns 16.

MAX([-1, -6, -1, 0, -1, -4], 3, 4, Item*Item)
2.

To avoid an error when you pass an empty array to this function, you could use the following expression. Note the example above is encapsulated in the following IF statement.

IF(COUNT([-1, -6, -1, 0, -1, -4]) > 0, MAX([-1, -6, -1, 0, -1, -4], 3, 4, Item* Item) , -1)