# Percentile based on already aggregated data

**URL:** <https://discuss.elastic.co/t/percentile-based-on-already-aggregated-data/94744>\
**Category:** Elasticsearch\
**Created:** [July 27, 2017, 5:46am UTC](https://discuss.elastic.co/t/percentile-based-on-already-aggregated-data/94744 "2017-07-27T05:46:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blayneliu](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@blayneliu](https://discuss.elastic.co/u/blayneliu)\
**Post date:** [July 27, 2017, 5:46am UTC](https://discuss.elastic.co/t/percentile-based-on-already-aggregated-data/94744/1 "2017-07-27T05:46:26Z")

</div>

Hi all,

There is a requirement from my project that we need to compute percentiles based on aggregated data. For instance we have the following data records:  
throughput count  
100 5  
200 1  
800 4

So ideally, we would like to compute percentile by treating the data as the following:  
100, 100, 100, 100, 100, 200, 800, 800, 800, 800

I wonder if ES can help in this case?

I searched in the forum and found there was a post from 2 years ago asking the same question, unfortunately there was no reply and seems like the post was closed.

Thanks in advance!  
Bin

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [July 27, 2017, 8:14am UTC](https://discuss.elastic.co/t/percentile-based-on-already-aggregated-data/94744/2 "2017-07-27T08:14:44Z")

</div>

One way to solve this would be to use [a script in the percentiles aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html#_script_6). Your script could output an array of length `count` in which every element is `throughput` and this should have the affect you want.

---

<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:** [August 24, 2017, 8:14am UTC](https://discuss.elastic.co/t/percentile-based-on-already-aggregated-data/94744/3 "2017-08-24T08:14:49Z")

</div>

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