25 Nov 2024 02:18 PM
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
Solved! Go to Solution.
25 Nov 2024 04:54 PM
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
26 Nov 2024 09:14 AM
Hi Kris,
Thank you, the collectArray() function was the bit I was missing.
Javin