# Elasticsearch - bucket aggregation selection

**URL:** <https://discuss.elastic.co/t/elasticsearch-bucket-aggregation-selection/54175>\
**Category:** Elasticsearch\
**Created:** [June 28, 2016, 3:22pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggregation-selection/54175 "2016-06-28T15:22:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![esap](https://avatars.discourse-cdn.com/v4/letter/e/7c8e57/32.png) [@esap](https://discuss.elastic.co/u/esap)\
**Post date:** [June 28, 2016, 3:22pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggregation-selection/54175/1 "2016-06-28T15:22:37Z")

</div>

Is it possible to perform child or pipeline agg on select buckets?

I have car sales records ("datesold" & "amountsold") and I create a monthly agg histogram. This gives me monthly buckets.

`"aggs": { "sales_per_month": { "date_histogram": { "field": "datesold", "interval": "month" } } }`

I want 2 sets of outputs (pipeline aggregation), average of "amountsold" for buckets until last month and another output for average of current month's bucket (last bucket). Is this possible?

---

<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, 10:39pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggregation-selection/54175/2 "2017-07-05T22:39:52Z")

</div>


