Declaring an array within a query and adding elements to it as the query iterates

I am trying to declare an array (of integers) within a query and add elements to it based on the result of an if condition, using one of the record columns in the query.

However I am unable to do this or find any official support documentation to do so. Could I please know if it is possible and/or have a solution if it is.

Thank you.

Javin

Id sound line a need for use of collectArray or collectDistinct aggregation functions. Please take a look at example below (collection even integers) and result :

data record(x=1),
  record(x=2),
  record(x=3),
  record(x=4),
  record(x=null)
| summarize {ax=arrayRemoveNulls(collectArray( if( x % 2==0, x )))}

It would be helpful if you could share your existing query.

Kris

Hi Kris,

Thank you, the collectArray() function was the bit I was missing.

Javin