# How to get max KEY:VALUE per event.id without using expand (JSON array)

**URL:** <https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323>\
**Category:** DQL\
**Tags:** dql, business-analytics, notebooks\
**Created:** [July 3, 2025, 4:34am UTC](https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323 "2025-07-03T04:34:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tracegazer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/tracegazer/32/32785_2.png) [@tracegazer](https://community.dynatrace.com/u/tracegazer)\
**Post date:** [July 3, 2025, 4:34am UTC](https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323/1 "2025-07-03T04:34:14Z")

</div>

Hi everyone,

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:

```python
[
  {"keyA": "valueA", "broadcast_time": 123456},
  {"keyA": "valueA", "broadcast_time": 153824},
  ...
]

```

What I need:

- Get the **maximum broadcast\_time value** ,
- **Per event.id** ,
- Without generating duplicated rows or breaking pipeline compatibility.

The only working solution so far is:

```python
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}

```

This works, but expand creates **one row per element** in the array, which **duplicates events** and **cannot be used in pipelines** , where expand is not allowed.

Is there any way to get the maximum broadcast\_time **per event.id**  **without using expand**?

Any ideas, workarounds or suggestions would be really appreciated.  
I’ve attached a sample rs.body\_result with dummy data.

Thanks in advance!  
[example.json](https://community.dynatrace.com/uploads/short-url/zmRoh1TJSi4oA9s3oTPa8KJ9g1W.json) (3.7 KB)

---

<div class="post-metadata">

**Author:** ![Dant3](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dant3/32/159_2.png) [@Dant3](https://community.dynatrace.com/u/Dant3)\
**Post date:** [July 8, 2025, 7:22pm UTC](https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323/2 "2025-07-08T19:22:09Z")

</div>

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.

You could do something like

**| fieldsadd datos[1][broadcast\_time], alias: valor1**  
**| fieldsadd datos[2][broadcast\_time], alias: valor2**  
**| fieldsadd datos[3][broadcast\_time], alias: valor3**  
**| fieldsadd datos[4][broadcast\_time], alias: valor4**  
**| fieldsadd array(valor1,valor2,valor3,valor4), alias: array\_valores**  
**| fieldsAdd arrayMax(array\_valores)**  
**| fieldsadd arraySize(datos)**

And avoid expand, you would need to hardcode the fieldsadd.

Result:

![Dant3_0-1752002406882.png](https://global.discourse-cdn.com/dynatrace/optimized/2X/b/b4133d506b4e06159837d80dd75972da65f37f14_2_690x33.png)

---

<div class="post-metadata">

**Author:** ![tracegazer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/tracegazer/32/32785_2.png) [@tracegazer](https://community.dynatrace.com/u/tracegazer)\
**Post date:** [July 9, 2025, 3:00pm UTC](https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323/3 "2025-07-09T15:00:55Z")

</div>

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.

```markup
| 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

```

Thank you, I really appreciate it!

---

<div class="post-metadata">

**Author:** ![Dant3](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dant3/32/159_2.png) [@Dant3](https://community.dynatrace.com/u/Dant3)\
**Post date:** [July 9, 2025, 10:23pm UTC](https://community.dynatrace.com/t/how-to-get-max-key-value-per-event-id-without-using-expand-json-array/52323/4 "2025-07-09T22:23:03Z")

</div>

Now that is a solution I didn’t thought about. Passing the first index value empty
