How can I get the nth element of an array?

I used ArrayAgg([City]) to create an array of cities. How do I grab the 2nd city from the left? What about the last city?


Getting the first or n element is pretty straightforward. You simply use the following:

ArrayAgg([City])[0] for the first element and so on for any nth element.

The last element is a bit more complex to retrieve dynamically. You’d have to first get the length of the array -1 and then use a combination of Sigma system functions with Snowflake’s get like so:

CallVariant("get", [City], CallNumber("array_size", [City]) - 1)