<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use a variable to access an element in an array? in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/How-to-use-a-variable-to-access-an-element-in-an-array/m-p/277534#M2105</link>
    <description>&lt;P&gt;Proper function if in preparation. For now you can use this formula&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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[])))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1747682701071.png" style="width: 790px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28077iE509BDF070AC7399/image-dimensions/790x326?v=v2" width="790" height="326" role="button" title="krzysztof_hoja_0-1747682701071.png" alt="krzysztof_hoja_0-1747682701071.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 May 2025 19:25:14 GMT</pubDate>
    <dc:creator>krzysztof_hoja</dc:creator>
    <dc:date>2025-05-19T19:25:14Z</dc:date>
    <item>
      <title>How to use a variable to access an element in an array?</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-use-a-variable-to-access-an-element-in-an-array/m-p/276801#M2044</link>
      <description>&lt;P&gt;I have an usecase to access the element from an array based on the value stored in another field.&lt;/P&gt;&lt;PRE&gt;data record(a=array(1,2,3,4,5))&lt;BR /&gt;| fieldsAdd random = random()&lt;BR /&gt;| fieldsAdd random_nummer = toLong((random*100)%arraySize(a))&lt;BR /&gt;| fieldsAdd test = a[random_nummer]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is this possible with dqlin the openpipeline processing step or any alternate ideas to implement this?&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 07:42:33 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-use-a-variable-to-access-an-element-in-an-array/m-p/276801#M2044</guid>
      <dc:creator>kumaravel</dc:creator>
      <dc:date>2025-05-09T07:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a variable to access an element in an array?</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-use-a-variable-to-access-an-element-in-an-array/m-p/277534#M2105</link>
      <description>&lt;P&gt;Proper function if in preparation. For now you can use this formula&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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[])))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1747682701071.png" style="width: 790px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28077iE509BDF070AC7399/image-dimensions/790x326?v=v2" width="790" height="326" role="button" title="krzysztof_hoja_0-1747682701071.png" alt="krzysztof_hoja_0-1747682701071.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 19:25:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-use-a-variable-to-access-an-element-in-an-array/m-p/277534#M2105</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-05-19T19:25:14Z</dc:date>
    </item>
  </channel>
</rss>

