# Calculating Average of Average

**URL:** https://discuss.elastic.co/t/calculating-average-of-average/31366
**Category:** Elasticsearch
**Created:** [September 29, 2015, 9:30pm UTC](https://discuss.elastic.co/t/calculating-average-of-average/31366 "2015-09-29T21:30:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Pradeep\_Gowda](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@Pradeep\_Gowda](https://discuss.elastic.co/u/Pradeep_Gowda)
#### Post date: [September 29, 2015, 9:30pm UTC](https://discuss.elastic.co/t/calculating-average-of-average/31366/1 "2015-09-29T21:30:35Z")

</div>

Hello Everyone,

I am trying to calculate Average of Average for the below data.

![](https://us1.discourse-cdn.com/elastic/original/2X/f/f5c1f8716e2d2455efaae431b5a5801031b8a2d2.png)

First I want to group the items and calculate the average of values. In the next Iteration, I want to calculate the average of the average what I calculated before. Currently I am able to get the first level average using below aggregation .

```
"aggs": {
        "item": {
          "terms": {
            "field": "item",
            "size": 0
          } , "aggs": {
            "value": {
              "avg": {
                "field": "value"
              } 
            } 
          } 
        } 

```

Can someone please help me to calculate the second level average?

Thanks.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 30, 2015, 9:07am UTC](https://discuss.elastic.co/t/calculating-average-of-average/31366/2 "2015-09-30T09:07:25Z")

</div>

You can't currently do that, pipeline aggs in ES 2.0 will do it though.

---

<div class="post-metadata">

### Author: ![tarunsapra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tarunsapra/32/3903_2.png) [@tarunsapra](https://discuss.elastic.co/u/tarunsapra)
#### Post date: [September 30, 2015, 3:37pm UTC](https://discuss.elastic.co/t/calculating-average-of-average/31366/3 "2015-09-30T15:37:38Z")

</div>

It's available in pipeline aggregation in ES 2.0 , you can read more about it here - [http://amsterdam.luminis.eu/2015/08/31/elasticsearch-2-0-and-pipeline-aggregations/](http://amsterdam.luminis.eu/2015/08/31/elasticsearch-2-0-and-pipeline-aggregations/)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:47pm UTC](https://discuss.elastic.co/t/calculating-average-of-average/31366/4 "2017-07-05T23:47:21Z")

</div>


