# Percentage of documents that have a given field value

**URL:** <https://discuss.elastic.co/t/percentage-of-documents-that-have-a-given-field-value/132684>\
**Category:** Elasticsearch\
**Created:** [May 21, 2018, 5:13pm UTC](https://discuss.elastic.co/t/percentage-of-documents-that-have-a-given-field-value/132684 "2018-05-21T17:13:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 21, 2018, 5:13pm UTC](https://discuss.elastic.co/t/percentage-of-documents-that-have-a-given-field-value/132684/1 "2018-05-21T17:13:55Z")

</div>

I have documents that contain several boolean fields. For each of those fields I want to know what percentage of documents have it set to true. Can elasticsearch tell me?

---

<div class="post-metadata">

**Author:** ![RahulD](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RahulD](https://discuss.elastic.co/u/RahulD)\
**Post date:** [May 21, 2018, 5:17pm UTC](https://discuss.elastic.co/t/percentage-of-documents-that-have-a-given-field-value/132684/2 "2018-05-21T17:17:09Z")

</div>

You can perform terms aggregation on each field that you want the fill rate for and calculate it using the values returned by elasticsearch each bucket. You'll have to use the other document count value if some of the documents do not contain this field.

---

<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:** [June 18, 2018, 5:17pm UTC](https://discuss.elastic.co/t/percentage-of-documents-that-have-a-given-field-value/132684/3 "2018-06-18T17:17:13Z")

</div>

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