Evaluates the function argument on all values in the array under the array argument overwriting the array. If the asArray argument is supplied, then array:eval() saves the result in an array under the given prefix. This overwrites existing arrays of that name.

The output array is always compacted, meaning that the array indices are guaranteed to be continuous, i.e. 0,1,2,....

ParameterTypeRequiredDefaultDescription
array[a]stringrequired  The array name in LogScale Array Syntax, for example for events with fields incidents[0], incidents[1], ... this would be incidents[], as in array:eval(array="incidents[0]", ....
asArraystringoptional[b]value passed to the array parameter The output array.
functionNon-aggregate functionrequired  The function to be applied to each element of the array. Must write a value to a field named the same as the output array.
varstringoptional[b]input array name Name of the variable to be used in the function argument.

[a] The argument name array can be omitted.

[b] Optional parameters use their default value unless explicitly set

Omitted Argument Names

The argument name for array can be omitted; the following forms of this function are equivalent:

logscale
array:eval("value[]",function="value")

and:

logscale
array:eval(array="value[]",function="value")

These examples show basic structure only; full examples are provided below.

array:eval() Examples

To square the value of each item in the array:

nohighlight
values [0] = 2
values [1] = 3
values [2] = 4

Use the following query function:

logscale
array:eval("values[]", asArray="squared[]", var=v, function={squared :=v*v})

The expected output is:

fieldvalue
squared[0]4
squared[1]9
squared[2]16