# Trouble making Bar Graph showing the most common value of a field over a given time

**URL:** https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864
**Category:** Kibana
**Created:** [October 12, 2016, 8:13pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864 "2016-10-12T20:13:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cb2015](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@cb2015](https://discuss.elastic.co/u/cb2015)
#### Post date: [October 12, 2016, 8:13pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864/1 "2016-10-12T20:13:32Z")

</div>

Hi Everyone,

I am trying to make a bar graph that will show the value of a field(storeinfo) with the highest count, every hour, for the past 24 hours. Basically, I want to to show the most frequent storeinfo in my logs, by hour, with the number of times it appeared on the y-axis, and the actual storeinfo and hour in the x-axis.

I currently have a poor workaround for this. My y-axis is set to count, I split the chart by columns as a date histogram with an hourly interval, and have my x-axis set to be a sub aggregation on the term storeinfo.raw ordered by count, descending, and a size of 1.

The attached picture is the result I get

 ![](https://us1.discourse-cdn.com/elastic/original/2X/9/9f0a577b81cc0e30373e5a1ccbd9703243bd949e.png)

My biggest issue with this result is that every value of storeinfo that is most frequent for at least one hour appears in every 1 hour chunk.

I think I need to do something like y=max(count(storeinfo.raw) (which I already basically have), and need to be able to control the x-axis labels better.

Any help would be appreciated

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [October 12, 2016, 11:26pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864/2 "2016-10-12T23:26:46Z")

</div>

Hey Cody,

Hmm, I wonder if it will help if you do an X-Axis Aggregation (Date Histogram) first, and then a Split Bars Sub-Aggregation (Terms) last?

Here's the kind of result I get:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/b/bf7d890360df22ea54d7d9cb6db814f335d64d7f.png)

Can you let me know if this helps at all?

Thanks,  
CJ

---

<div class="post-metadata">

### Author: ![cb2015](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@cb2015](https://discuss.elastic.co/u/cb2015)
#### Post date: [October 13, 2016, 8:31pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864/3 "2016-10-13T20:31:06Z")

</div>

That worked beautifully!

Thank you so much cjcenizal!  
Here's what I got with your help:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/1/117638372783f762e1f515fedb35c438f06189cd.png)

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [October 13, 2016, 9:05pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864/4 "2016-10-13T21:05:56Z")

</div>

Awesome!! Glad I could help, Cody!

CJ

---

<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, 1:36pm UTC](https://discuss.elastic.co/t/trouble-making-bar-graph-showing-the-most-common-value-of-a-field-over-a-given-time/62864/5 "2017-07-06T13:36:43Z")

</div>


