<?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 DQL Matching and comparing on two arrays in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260884#M1373</link>
    <description>&lt;P&gt;Hello DQL Experts,&lt;/P&gt;&lt;P&gt;Running into a situation where I have two arrays. I want to be able to make records based on the comparison of these two arrays without using the&amp;nbsp;&lt;STRONG&gt;expand or summarize&amp;nbsp;&lt;/STRONG&gt;commands.&lt;/P&gt;&lt;P&gt;I can't really articulate it well so here's an example of what I'm looking for.&lt;/P&gt;&lt;P&gt;array1 = ["cat", "cat", "dog", "dog", "dog", "snake"]&lt;/P&gt;&lt;P&gt;array2 = ["cat", "dog", "snake"]&lt;/P&gt;&lt;P&gt;Desired Output:&lt;BR /&gt;totals = { "cat":2, "dog":3, "snake":1 }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Oct 2024 20:17:24 GMT</pubDate>
    <dc:creator>calfano</dc:creator>
    <dc:date>2024-10-28T20:17:24Z</dc:date>
    <item>
      <title>DQL Matching and comparing on two arrays</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260884#M1373</link>
      <description>&lt;P&gt;Hello DQL Experts,&lt;/P&gt;&lt;P&gt;Running into a situation where I have two arrays. I want to be able to make records based on the comparison of these two arrays without using the&amp;nbsp;&lt;STRONG&gt;expand or summarize&amp;nbsp;&lt;/STRONG&gt;commands.&lt;/P&gt;&lt;P&gt;I can't really articulate it well so here's an example of what I'm looking for.&lt;/P&gt;&lt;P&gt;array1 = ["cat", "cat", "dog", "dog", "dog", "snake"]&lt;/P&gt;&lt;P&gt;array2 = ["cat", "dog", "snake"]&lt;/P&gt;&lt;P&gt;Desired Output:&lt;BR /&gt;totals = { "cat":2, "dog":3, "snake":1 }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 20:17:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260884#M1373</guid>
      <dc:creator>calfano</dc:creator>
      <dc:date>2024-10-28T20:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: DQL Matching and comparing on two arrays</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260905#M1375</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/58627"&gt;@calfano&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming that you want to count in array1 the number of occurence of values in array2, I'd do something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data record()
| fieldsAdd array1 = Array("cat", "dog", "snake", "dog", "dog", "snake")
| fieldsAdd array2 = Array("cat", "dog", "snake", "cow")
| fieldsAdd array1 = arraySort(array1, direction:"ascending")
| fieldsAdd result = iCollectArray(concat(array2[],":",
        if(arrayLastIndexOf(array1, array2[])&amp;gt;=0, arrayLastIndexOf(array1, array2[])-arrayIndexOf(array1,array2[])+1, 
          else:arrayLastIndexOf(array1, array2[]))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GerardJ_0-1730189113409.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/24221iD58482C0CBC10F59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GerardJ_0-1730189113409.png" alt="GerardJ_0-1730189113409.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 08:24:01 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260905#M1375</guid>
      <dc:creator>GerardJ</dc:creator>
      <dc:date>2024-10-29T08:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: DQL Matching and comparing on two arrays</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260939#M1381</link>
      <description>&lt;P&gt;WOW That's it! Thank you so much. This is very impressive!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 12:48:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Matching-and-comparing-on-two-arrays/m-p/260939#M1381</guid>
      <dc:creator>calfano</dc:creator>
      <dc:date>2024-10-29T12:48:24Z</dc:date>
    </item>
  </channel>
</rss>

