# Average and Count metric in the same Vertical Bar

**URL:** <https://discuss.elastic.co/t/average-and-count-metric-in-the-same-vertical-bar/217067>\
**Category:** Kibana\
**Created:** [January 29, 2020, 7:26pm UTC](https://discuss.elastic.co/t/average-and-count-metric-in-the-same-vertical-bar/217067 "2020-01-29T19:26:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Albertengo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pablo_albertengo/32/47685_2.png) [@Pablo\_Albertengo](https://discuss.elastic.co/u/Pablo_Albertengo)\
**Post date:** [January 29, 2020, 7:26pm UTC](https://discuss.elastic.co/t/average-and-count-metric-in-the-same-vertical-bar/217067/1 "2020-01-29T19:26:33Z")

</div>

Hi guys!  
I need to build a visualization like the one I'm attaching.

![Comparative](https://us1.discourse-cdn.com/elastic/original/3X/3/e/3e5ca3cc96de45ca7d781e7d30337148a24f927b.png)

Suppose that I have an index with a field called countryCode. Also I have a timestamp field related to each document in the index

The first value in the graphic correspond to the count of occurrences of the countryCode X today.  
The second value in the graphic correspond to the average occurrences per day of that same countryCode X in the previous 7 days.

Is it possible to do with a Vertical Bar?  
In another case ... what other option do I have?

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [January 29, 2020, 9:29pm UTC](https://discuss.elastic.co/t/average-and-count-metric-in-the-same-vertical-bar/217067/2 "2020-01-29T21:29:55Z")

</div>

It's almost possible to do this in Kibana's basic bar chart, but we don't support configuring the moving average aggregation. It uses a window of 5 by default, which won't give you the 7 days you want. There is a [GitHub issue](https://github.com/elastic/kibana/issues/10734) for this that I've reopened.

However, there's another way! You can use [TSVB](https://www.elastic.co/guide/en/kibana/7.5/TSVB.html) to do what you want. You'll just need to configure two metrics, a simple count and then a moving average of the count with a window of 7. It would look like this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02fcf39bb48cd04328e1908636f1da1126f5db9f.png)

Then in the "Panel options" tab you'll want to set the interval to `1d` and specify the countryCode you want to filter on in the `Panel filter` input. That would look like this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4a8f576485e40ce58fd4842061dd12da736dce27.png)

---

<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:** [February 26, 2020, 9:29pm UTC](https://discuss.elastic.co/t/average-and-count-metric-in-the-same-vertical-bar/217067/3 "2020-02-26T21:29:55Z")

</div>

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