# \[aggregations\] Is it possible to calculate fields based on multiple aggregations?

**URL:** <https://discuss.elastic.co/t/aggregations-is-it-possible-to-calculate-fields-based-on-multiple-aggregations/18324>\
**Category:** Elasticsearch\
**Created:** [June 25, 2014, 9:28am UTC](https://discuss.elastic.co/t/aggregations-is-it-possible-to-calculate-fields-based-on-multiple-aggregations/18324 "2014-06-25T09:28:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_Mueller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_mueller/32/1466_2.png) [@Mario\_Mueller](https://discuss.elastic.co/u/Mario_Mueller)\
**Post date:** [June 25, 2014, 9:28am UTC](https://discuss.elastic.co/t/aggregations-is-it-possible-to-calculate-fields-based-on-multiple-aggregations/18324/1 "2014-06-25T09:28:54Z")

</div>

Given is a query: [https://gist.github.com/xenji/a99342d3cfc5864ad6e4](https://gist.github.com/xenji/a99342d3cfc5864ad6e4)  
The data: Tracking data from a website. Browser and Browser Version are  
available on the first level of the document as string values.

The goal:

- Get a term agg. over all browsers and nested over their versions (DONE)
- Get the overall count of docs that have a browser field filled (DONE)
- Calculate the percentile of the version related to the count of a  
browser. (Browser Firefox, Version 25.0 is 25% of all Firefox hits)
- Calculate the percentile of the browser related to the overall count (All  
Firefox hits are 15% of all hits)

The last two are driving me mad. Is this possible at all? I can do it in  
the application for sure, but I want to know if this is possible to be done  
in ES.

Any hints?

Regards,  
Mario

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/42222fb8-7e9d-49ce-a305-a0ded2a1ac65%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/42222fb8-7e9d-49ce-a305-a0ded2a1ac65%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:19am UTC](https://discuss.elastic.co/t/aggregations-is-it-possible-to-calculate-fields-based-on-multiple-aggregations/18324/2 "2017-07-06T01:19:54Z")

</div>


