# Terms stats with precentage

**URL:** https://discuss.elastic.co/t/terms-stats-with-precentage/8143
**Category:** Elasticsearch
**Created:** [June 18, 2012, 12:59pm UTC](https://discuss.elastic.co/t/terms-stats-with-precentage/8143 "2012-06-18T12:59:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Yehuda\_Zargarov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehuda_zargarov/32/2164_2.png) [@Yehuda\_Zargarov](https://discuss.elastic.co/u/Yehuda_Zargarov)
#### Post date: [June 18, 2012, 12:59pm UTC](https://discuss.elastic.co/t/terms-stats-with-precentage/8143/1 "2012-06-18T12:59:35Z")

</div>

Hi

I have an index with the following fields: id (int), num1 (int), num2  
(int), div (double).  
The field "div" is the division on num1/num2.  
I want to get the aggregated division for each id. Using terms stats on  
"div" field is not good since you can't add percentages.  
The long way would be doing 2 terms stats - on num1 and on num2, and divide  
the sums for each id.  
Is there a way to do that with 1 terms stats? maybe using value script  
somehow?

Thanks

---

<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, 3:23am UTC](https://discuss.elastic.co/t/terms-stats-with-precentage/8143/2 "2017-07-06T03:23:36Z")

</div>


