# Sum across Average of buckets for Metric

**URL:** https://discuss.elastic.co/t/sum-across-average-of-buckets-for-metric/33197
**Category:** Elasticsearch
**Created:** [October 29, 2015, 12:34am UTC](https://discuss.elastic.co/t/sum-across-average-of-buckets-for-metric/33197 "2015-10-29T00:34:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![goodsky](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@goodsky](https://discuss.elastic.co/u/goodsky)
#### Post date: [October 29, 2015, 12:34am UTC](https://discuss.elastic.co/t/sum-across-average-of-buckets-for-metric/33197/1 "2015-10-29T00:34:52Z")

</div>

I have data in elastic search that I want to split into buckets based on an ID, average values within each bucket and then sum the values between buckets. I have searched about nested aggregations from the elastic search website, but it seems like this sort of map reducing functionality may not be supported.

Can anyone confirm for me if this sort of script can be written in Elasticsearch?

---

<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: [October 29, 2015, 1:50am UTC](https://discuss.elastic.co/t/sum-across-average-of-buckets-for-metric/33197/2 "2015-10-29T01:50:37Z")

</div>

You're probably after pipeline aggs, aggs on aggs, that is in 2.0.

---

<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:41pm UTC](https://discuss.elastic.co/t/sum-across-average-of-buckets-for-metric/33197/3 "2017-07-05T23:41:57Z")

</div>


