# Calculate average in Kibana visualizations

**URL:** <https://discuss.elastic.co/t/calculate-average-in-kibana-visualizations/152668>\
**Category:** Kibana\
**Created:** [October 16, 2018, 1:29pm UTC](https://discuss.elastic.co/t/calculate-average-in-kibana-visualizations/152668 "2018-10-16T13:29:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [October 16, 2018, 3:26pm UTC](https://discuss.elastic.co/t/calculate-average-in-kibana-visualizations/152668/2 "2018-10-16T15:26:17Z")

</div>

Hi,

what you are looking for is the bucket script aggregation, which allows you to calculate the outcome of several metric aggregations. This is not yet completely implemented in Kibana, see also [https://github.com/elastic/kibana/issues/4707](https://github.com/elastic/kibana/issues/4707)

Nevertheless you could actually achieve that (using Bucket Script aka Calculation) in Visual Builder, where you would just create two sum aggregations (for times and time\_sum) and then create a script, that will divide those two and draw this one.

The same could also be achieved in the more stable timelion visualization, by using a script that looks something like:

```auto
.es(metric=sum:times).divide(.es(metric=sum:time_sum))

```

And switching the interval selector to using `5m`.

Cheers,  
Tim

---

_[View the full topic](https://discuss.elastic.co/t/calculate-average-in-kibana-visualizations/152668)._
