<?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 get max KEY:VALUE per event.id without using expand (JSON array) in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281081#M2261</link>
    <description>&lt;P&gt;Problem is that if you dont know how many objects you have in the content, hard to do. You can´t do a loop/while in DQL.&lt;/P&gt;&lt;P&gt;You could do something like&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;| fieldsadd datos[1][broadcast_time], alias: valor1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[2][broadcast_time], alias: valor2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[3][broadcast_time], alias: valor3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[4][broadcast_time], alias: valor4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd array(valor1,valor2,valor3,valor4), alias: array_valores&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsAdd arrayMax(array_valores)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd arraySize(datos)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And avoid expand, you would need to hardcode the fieldsadd.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dant3_0-1752002406882.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28876i559CA53AA2D68F58/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dant3_0-1752002406882.png" alt="Dant3_0-1752002406882.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2025 19:22:09 GMT</pubDate>
    <dc:creator>Dant3</dc:creator>
    <dc:date>2025-07-08T19:22:09Z</dc:date>
    <item>
      <title>How to get max KEY:VALUE per event.id without using expand (JSON array)</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/280649#M2243</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m working with Business Events in Dynatrace and facing an issue I can't solve. I have a string field named rs.body_result that contains a JSON_ARRAY of objects. Each object includes a broadcast_time key (numeric long). Example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[
  {"keyA": "valueA", "broadcast_time": 123456},
  {"keyA": "valueA", "broadcast_time": 153824},
  ...
]&lt;/LI-CODE&gt;&lt;P&gt;What I need:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Get the &lt;STRONG&gt;maximum broadcast_time value&lt;/STRONG&gt;,&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Per event.id&lt;/STRONG&gt;,&lt;/LI&gt;&lt;LI&gt;Without generating duplicated rows or breaking pipeline compatibility.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The only working solution so far is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fetch bizevents
| parse rs.body_result, """JSON_ARRAY:parsed_json_elements"""
| expand parsed_json_elements
| fieldsFlatten parsed_json_elements
| fields event.id, time = parsed_json_elements[broadcast_time]
| summarize max(time) by: {event.id}&lt;/LI-CODE&gt;&lt;P&gt;This works, but expand creates &lt;STRONG&gt;one row per element&lt;/STRONG&gt; in the array, which &lt;STRONG&gt;duplicates events&lt;/STRONG&gt; and &lt;STRONG&gt;cannot be used in pipelines&lt;/STRONG&gt;, where expand is not allowed.&lt;/P&gt;&lt;P&gt;Is there any way to get the maximum broadcast_time &lt;STRONG&gt;per event.id&lt;/STRONG&gt; &lt;STRONG&gt;without using expand&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Any ideas, workarounds or suggestions would be really appreciated.&lt;BR /&gt;I’ve attached a sample rs.body_result with dummy data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jul 2025 04:34:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/280649#M2243</guid>
      <dc:creator>tracegazer</dc:creator>
      <dc:date>2025-07-03T04:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max KEY:VALUE per event.id without using expand (JSON array)</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281081#M2261</link>
      <description>&lt;P&gt;Problem is that if you dont know how many objects you have in the content, hard to do. You can´t do a loop/while in DQL.&lt;/P&gt;&lt;P&gt;You could do something like&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;| fieldsadd datos[1][broadcast_time], alias: valor1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[2][broadcast_time], alias: valor2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[3][broadcast_time], alias: valor3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd datos[4][broadcast_time], alias: valor4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd array(valor1,valor2,valor3,valor4), alias: array_valores&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsAdd arrayMax(array_valores)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| fieldsadd arraySize(datos)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And avoid expand, you would need to hardcode the fieldsadd.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dant3_0-1752002406882.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28876i559CA53AA2D68F58/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dant3_0-1752002406882.png" alt="Dant3_0-1752002406882.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 19:22:09 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281081#M2261</guid>
      <dc:creator>Dant3</dc:creator>
      <dc:date>2025-07-08T19:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max KEY:VALUE per event.id without using expand (JSON array)</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281174#M2270</link>
      <description>&lt;P&gt;Hi, your comment was really helpful — I found a way to iterate through the array, which I honestly had no idea how to approach before, but your DQL example pointed me in the right direction.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| parse rs.body_result, """JSON_ARRAY:parsed_json_elements"""
| fieldsAdd array(parsed_json_elements[][broadcast_time]), alias: MAX
| fieldsAdd arraySize(parsed_json_elements), alias: COUNT_MAX&lt;/LI-CODE&gt;&lt;P&gt;Thank you, I really appreciate it!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 15:00:55 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281174#M2270</guid>
      <dc:creator>tracegazer</dc:creator>
      <dc:date>2025-07-09T15:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max KEY:VALUE per event.id without using expand (JSON array)</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281209#M2274</link>
      <description>&lt;P&gt;Now that is a solution I didn't thought about. Passing the first index value empty&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 22:23:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-get-max-KEY-VALUE-per-event-id-without-using-expand-JSON/m-p/281209#M2274</guid>
      <dc:creator>Dant3</dc:creator>
      <dc:date>2025-07-09T22:23:03Z</dc:date>
    </item>
  </channel>
</rss>

