cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use a variable to access an element in an array?

kumaravel
Contributor

I have an usecase to access the element from an array based on the value stored in another field.

data record(a=array(1,2,3,4,5))
| fieldsAdd random = random()
| fieldsAdd random_nummer = toLong((random*100)%arraySize(a))
| fieldsAdd test = a[random_nummer]

 Is this possible with dqlin the openpipeline processing step or any alternate ideas to implement this?

Dynatrace Certified Associate
1 REPLY 1

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

Proper function if in preparation. For now you can use this formula

data record(a=array(1,2,3,4,5))
| fieldsAdd random = random()
| fieldsAdd random_nummer = toLong((random*100)%arraySize(a))
| fieldsAdd test = arrayFirst(iCollectarray(if(iIndex()==random_nummer,a[])))

krzysztof_hoja_0-1747682701071.png

 

Featured Posts