# How to split count based on field entry in visualization?

**URL:** <https://discuss.elastic.co/t/how-to-split-count-based-on-field-entry-in-visualization/83366>\
**Category:** Kibana\
**Created:** [April 24, 2017, 7:28am UTC](https://discuss.elastic.co/t/how-to-split-count-based-on-field-entry-in-visualization/83366 "2017-04-24T07:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [April 24, 2017, 7:28am UTC](https://discuss.elastic.co/t/how-to-split-count-based-on-field-entry-in-visualization/83366/1 "2017-04-24T07:28:27Z")

</div>

Hi,

I am using ELK GA 5.0.0. I am trying to create a visualization like below;

![](https://us1.discourse-cdn.com/elastic/original/3X/3/7/376fca304d69c41d9c869943b5c9bfec2a408f00.png "bar chart")

The picture represents count of logs with `user_id` having values `USER_1` and `USER_2` in separate graphs, and X-Axis having date histogram daily. In my visualization, to get the count of log entries with `user_id` value `USER_1`, I entered the below code in the JSON Input of Count Aggregation;

```
{
  "query": {
    "match": {
      "user_id": {
        "query": "USER_1"
      }
    }
  }
}

```

but still it shows the complete count. How can I create a visualization that I am trying to achieve?

Thanks in advance..

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [April 24, 2017, 10:56pm UTC](https://discuss.elastic.co/t/how-to-split-count-based-on-field-entry-in-visualization/83366/2 "2017-04-24T22:56:12Z")

</div>

To do this you want to use a "bucket" aggregation, then choose "split bars" and use a "terms" aggregation on the field container both "USER\_1" and "USER\_2"

---

<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:** [May 22, 2017, 11:09pm UTC](https://discuss.elastic.co/t/how-to-split-count-based-on-field-entry-in-visualization/83366/3 "2017-05-22T23:09:21Z")

</div>

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