# Summarize Array Entries by Maximum Value per Key Using Dynatrace DQL

**URL:** <https://community.dynatrace.com/t/summarize-array-entries-by-maximum-value-per-key-using-dynatrace-dql/50636>\
**Category:** DQL\
**Tags:** dql\
**Created:** [March 10, 2025, 10:44am UTC](https://community.dynatrace.com/t/summarize-array-entries-by-maximum-value-per-key-using-dynatrace-dql/50636 "2025-03-10T10:44:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joostm](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@joostm](https://community.dynatrace.com/u/joostm)\
**Post date:** [March 10, 2025, 10:44am UTC](https://community.dynatrace.com/t/summarize-array-entries-by-maximum-value-per-key-using-dynatrace-dql/50636/1 "2025-03-10T10:44:46Z")

</div>

_Summary:&nbsp;This post explains how to use DQL to summarize multiple array elements by picking the maximum value for each matching key. It provides example queries and discusses data‑structuring considerations._

I have a dataset of 1000+ hosts, each with a fixed-sized array of 120+ numeric values. Most hosts have only one entry, but a few can have multiple rows. I want to summarize those, per host, with the maximum value of each element within the array. Which is the best (most economical) way to do this in DQL?

Example extract:

| **host** | **data** |
| --- | --- |
| host\_A | (3, **8** ,6) |
| host\_A | ( **5** ,0, **7** ) |
| host\_B | (1, **7** , **3** ) |
| host\_B | (4,6,2) |
| host\_B | ( **8** ,5,2) |
| host\_C | (5,3,9) |
| host\_D | (4,5,6) |

Desired outcome:

| **host** | **result** |
| --- | --- |
| host\_A | (5,8,7) |
| host\_B | (8,7,3) |
| host\_C | (5,3,9) |
| host\_D | (4,5,6) |

I was looking into ‘dedup’, summarize, and max() , takeMax, functions, but didn’t get any further than filtering on the entry with the highest first element of the array, per host

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [March 10, 2025, 12:11pm UTC](https://community.dynatrace.com/t/summarize-array-entries-by-maximum-value-per-key-using-dynatrace-dql/50636/2 "2025-03-10T12:11:21Z")

</div>

Hi&nbsp;[@joostm](https://community.dynatrace.com/user/76330)

One way how you could achieve this is with summarize, please have a look:

```markup
data record(content = """host_A	(3,8,6)
host_A	(5,0,7)
host_B	(1,7,3)
host_B	(4,6,2)
host_B	(8,5,2)
host_C	(5,3,9)
host_D	(4,5,6)""")
| parse content, """ARRAY{STRUCTURE{LD:host '	' LD:arr }:i (LF|EOS)}{1,}:arr
"""
| expand elem = arr 
| fields host = elem[host], arr = elem[arr]
| parse arr, """'(' ARRAY{LONG:i (','|')')}{1,}:data"""
| summarize result = arrayDistinct(arrayFlatten((collectArray(data)))), by: { host }

```

Best,  
Sini
