# Average of 2 arrays by a field

**URL:** <https://community.dynatrace.com/t/average-of-2-arrays-by-a-field/48582>\
**Category:** DQL\
**Tags:** dql\
**Created:** [October 28, 2024, 9:52am UTC](https://community.dynatrace.com/t/average-of-2-arrays-by-a-field/48582 "2024-10-28T09:52:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elenaperez](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/elenaperez/32/38054_2.png) [@elenaperez](https://community.dynatrace.com/u/elenaperez)\
**Post date:** [October 28, 2024, 9:52am UTC](https://community.dynatrace.com/t/average-of-2-arrays-by-a-field/48582/1 "2024-10-28T09:52:50Z")

</div>

Hi team,

Having the following query:

```markup
timeseries value = avg(dt.cloud.azure.vm.cpu_usage), by: {azure.location, azure.management_group, azure.resource.name, azure.subscription, azure.vm_scale_set.name, dt.entity.azure_region, dt.entity.azure_vm, dt.source_entity, dt.source_entity.type}
| filter contains(azure.resource.name, "primary00") or contains(azure.resource.name, "primary01")
| parse azure.resource.name, "LD 'primary0' INT:number"

```

I’d like to get in a timeseries the average of the arrays by number. Meaning, for all arrays with number==0, an average of the values of the arrays and the same for number==1.

How could I achieve this? arrayAvg doesn’t seem to work for this use case.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [November 20, 2024, 8:41pm UTC](https://community.dynatrace.com/t/average-of-2-arrays-by-a-field/48582/2 "2024-11-20T20:41:11Z")

</div>

You need to use integrative expressions in _ **summary** _ command.

```markup
timeseries value = avg(dt.cloud.azure.vm.cpu_usage), 
  by: {azure.location, azure.management_group, azure.resource.name, azure.subscription, azure.vm_scale_set.name, 
  dt.entity.azure_region, dt.entity.azure_vm, dt.source_entity, dt.source_entity.type}
| filter contains(azure.resource.name, "primary00") or contains(azure.resource.name, "primary01")
| parse azure.resource.name, "LD 'primary0' INT:number"
| summarize {value=avg(value[])}, by: {interval, timeframe, number}

```

This query will give 2 timeseries for 2 possible values of “number”. Of course you can split data as you with by adding more of available dimensions retrieved by _ **timeseries** _ command.

Please also take a look a other examples in our documentation:&nbsp;[DQL timeseries examples for Metrics — Dynatrace Docs](https://docs.dynatrace.com/docs/analyze-explore-automate/metrics/dql-examples#example-17-split-cpu-usage-by-kubernetes-annotations)
