# Pipeline aggregation on average aggregation

**URL:** <https://discuss.elastic.co/t/pipeline-aggregation-on-average-aggregation/265718>\
**Category:** Elasticsearch\
**Created:** [February 28, 2021, 11:35am UTC](https://discuss.elastic.co/t/pipeline-aggregation-on-average-aggregation/265718 "2021-02-28T11:35:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zagmon](https://avatars.discourse-cdn.com/v4/letter/z/bcef8e/32.png) [@zagmon](https://discuss.elastic.co/u/zagmon)\
**Post date:** [February 28, 2021, 11:35am UTC](https://discuss.elastic.co/t/pipeline-aggregation-on-average-aggregation/265718/1 "2021-02-28T11:35:05Z")

</div>

```auto
Hello,

Having index contain these fields: user_id and score (integer between 0-100).
Need to do the following:
1. Calculate average score per user.
2. Create 4 buckets with the count of users score:
  Bucket 1: users with average score 0-25
  Bucket 2: users with average score 26-50
  Bucket 3: users with average score 51-75
  Bucket 4: users with average score 76-100

According to my readings I found that:
1. It is not possible to perform pipeline bucket aggregation with average as input.
2. It is not possible to pass sub-aggregation to average aggregation.

Keep in mind that the number of distinct users in the index might be hundred of thousands so it is a major performance issue to retrieve the average aggregation results (needs pagination) and process it in the code.

How can that be accomplished?   

I will appreciate any help on that.

Thanks a lot
Zvi

```

---

<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:** [March 28, 2021, 11:35am UTC](https://discuss.elastic.co/t/pipeline-aggregation-on-average-aggregation/265718/2 "2021-03-28T11:35:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
