# Average number of documents per buckets

**URL:** <https://discuss.elastic.co/t/average-number-of-documents-per-buckets/221323>\
**Category:** Kibana\
**Created:** [February 27, 2020, 8:14pm UTC](https://discuss.elastic.co/t/average-number-of-documents-per-buckets/221323 "2020-02-27T20:14:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![suite800](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suite800/32/63477_2.png) [@suite800](https://discuss.elastic.co/u/suite800)\
**Post date:** [February 27, 2020, 8:14pm UTC](https://discuss.elastic.co/t/average-number-of-documents-per-buckets/221323/1 "2020-02-27T20:14:28Z")

</div>

Suppose I have a mapping

```auto
{
    "properties": {
        "jobName": {
            "type": "keyword"
        },
      "jobNumber": {
            "type": "long"
        },
      ...
}

```

What I am trying to do is to get metrics of the average number of document for each jobName.

If there are 2000 entries for jobName: foo and jobNumber: 123, and 1000 entries for jobName: foo and jobNumber: 456, then it should produce 1500 for jobName: foo. It will do the same for jobName: bar, jobName: baz, etc.

I've been playing with metrics visualization to achieve this but can't figure out how to do so, let alone not sure if this is the right visualization tool.

Appreciate your help.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [February 28, 2020, 12:48pm UTC](https://discuss.elastic.co/t/average-number-of-documents-per-buckets/221323/2 "2020-02-28T12:48:56Z")

</div>

It sounds like you can do this with the metric visualization and the "avg bucket" aggregation (host.keyword would be jobNumber in your case):

 ![Screenshot 2020-02-28 at 13.51.29](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02c1c56dedaca061fead3137570a3ced42592621.png)

If you want to do this per jobName, you can add a bucket terms aggregation on jobName

 ![Screenshot 2020-02-28 at 13.53.18](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fb8e4dd221612b2a85639f448d4981d0493e7a62.png)

This will give you the average count of entries per jobNumber per jobName

---

<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:** [March 27, 2020, 12:49pm UTC](https://discuss.elastic.co/t/average-number-of-documents-per-buckets/221323/3 "2020-03-27T12:49:01Z")

</div>

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