ARRAY
Use ARRAY to group related items into a single list — customer ratings, product IDs, pricing tiers, or any collection you need to loop through, filter, or calculate with.
How it works
ARRAY(value1, value2, value3, ...)value1, value2, ...- Items to include in the list (can be numbers, text, objects, or even other lists)
Returns a new list containing all the values you provided. Accepts any number of arguments.
Examples
Group customer ratings for analysis
Collect multiple feedback scores to calculate averages or totals.
CUSTOMER_RATINGS := ARRAY(4, 5, 3, 4, 5)
AVERAGE_RATING := MEAN(CUSTOMER_RATINGS)Creates a list of ratings that can be passed to MEAN(), LEN(), or other list functions.
Build a list of selected product IDs
Track which products a customer added to their order for batch processing.
SELECTED_PRODUCTS := ARRAY(PRODUCT_1.ID, PRODUCT_2.ID, PRODUCT_3.ID)
TOTAL_ITEMS := LEN(SELECTED_PRODUCTS)Creates a list useful for order creation, inventory checks, or displaying cart contents.
Create a pricing comparison table
Set up multiple price points to show customers their options.
PRICE_TIERS := ARRAY(STANDARD_PRICE, DISCOUNTED_PRICE, PROMO_PRICE)
BEST_PRICE := MIN(PRICE_TIERS)Makes it easy to loop through all pricing options or find the lowest price.
Common mistakes
Accidental nesting -
ARRAY(MY_LIST)creates a nested list[[...]]ifMY_LISTis already a list. UseMY_LISTdirectly instead.Arrays are 0-indexed - The first element is at position 0. Use
INDEX(ARRAY(10, 20, 30), 0)to get10, not position 1.Bracket notation causes errors -
ARRAY(1,2,3)[1]is invalid syntax. UseINDEX(ARRAY(1,2,3), 1)instead.
When to use alternatives
Creating a sequence of numbers: Use RANGE -
RANGE(1, 10)is cleaner thanARRAY(1,2,3,4,5,6,7,8,9,10)Adding items to an existing list: Use PUSH or EXTEND to append values without recreating the entire array
Related functions
RANGE, MAP, FILTER, PUSH, EXTEND, INDEX