# Doc\_count calculations

**URL:** <https://discuss.elastic.co/t/doc-count-calculations/61484>\
**Category:** Elasticsearch\
**Created:** [September 26, 2016, 7:03am UTC](https://discuss.elastic.co/t/doc-count-calculations/61484 "2016-09-26T07:03:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sruthi](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sruthi](https://discuss.elastic.co/u/sruthi)\
**Post date:** [September 26, 2016, 7:03am UTC](https://discuss.elastic.co/t/doc-count-calculations/61484/1 "2016-09-26T07:03:51Z")

</div>

Is there any way to use the doc\_count value of an aggregation for further calculations?  
Below is a part of a terms aggregation result I am working on.  
"buckets": [  
{  
"key": "All",  
"doc\_count": 15  
},  
{  
"key": "completed",  
"doc\_count": 10  
}  
}  
]  
I need to find the difference between doc\_count. for eg:  
{  
"key": "InProgress",  
"doc\_count": 5  
}  
Is it possible to get in one query?

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [September 26, 2016, 9:56pm UTC](https://discuss.elastic.co/t/doc-count-calculations/61484/2 "2016-09-26T21:56:03Z")

</div>

It sounds like you want something like Pipeline Aggregations, which allow you to perform computation on metric aggregations.

In particular, you may want to check out the derivative pipeline agg: [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-pipeline.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-pipeline.html)

---

<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:17pm UTC](https://discuss.elastic.co/t/doc-count-calculations/61484/3 "2017-07-05T22:17:08Z")

</div>


