Skip to main content

ARRAYINDEX

ARRAYINDEX returns either a string or an integer from an array, string or integer at the specified index in the given value/array.

The index in this function starts from 1 and not 0.

Syntax

string  ARRAYINDEX(string[] values, int index)
int? ARRAYINDEX(int[] values, int index)

Example

If you had an array of values in a column (MyArrayColumn) and knew that the 4th item in the array was the value you needed to extract you could do this using:

ARRAYINDEX(MyArrayColumn, 4)

This would then return the fourth (4th) item in the array as the result for each row.


You can also use this in combination with other functions.

For example this could be used to gather the domain from an email with the combined use of the SPLIT function.

ARRAYINDEX(SPLIT("support@simego.com","@"),2)

This would return the result 'simego.com'.

You could modify the above example to use an email column so that each row of data had the domain extracted.

ARRAYINDEX(SPLIT(EmailAddress, "@"),2)