ELEMENTAT function

Synopsis
This function returns the value of the element at the specified index. If the array is empty, the function returns an error.
Variations
ELEMENTAT(SourceArray, Index)
Returns the value of the element at the specified index.
Parameters
SourceArray

Specifies the array to extract a value from.

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

Specifies the index to use to reference the value within the array.

Supported types: Numeric.
Returns
Returned types: Numeric; Boolean; String; Point; Object.
Examples
1.

In the following example, the index specified is 2, so the function returns the second element, "Tigers".

ELEMENTAT(["Lions", "Tigers", "Bears", "Oh", "My"], 2)
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(["Lions", "Tigers", "Bears", "Oh", "My"]) > 0, ELEMENTAT(["Lions", "Tigers", "Bears", "Oh", "My"], 2) , -1)