# Calculation of Average

**URL:** <https://discuss.elastic.co/t/calculation-of-average/269325>\
**Category:** Kibana\
**Created:** [April 6, 2021, 11:44am UTC](https://discuss.elastic.co/t/calculation-of-average/269325 "2021-04-06T11:44:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivekshukla](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@vivekshukla](https://discuss.elastic.co/u/vivekshukla)\
**Post date:** [April 6, 2021, 11:44am UTC](https://discuss.elastic.co/t/calculation-of-average/269325/1 "2021-04-06T11:44:02Z")

</div>

Hi Team,

I am using Metric Bar to find the average time for below scenario:

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

Need to find Average time = Sum of Duration / Sum( Number of Attempts)

Provided Aggregation are not helpful in Metric Bar for above calculation. Is there any way to achieve this? Or I am missing something?

Note: Duration is a Scripted Field.  
Kibana: 7.4

---

<div class="post-metadata">

**Author:** ![jportner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jportner/32/75692_2.png) [@jportner](https://discuss.elastic.co/u/jportner)\
**Post date:** [April 7, 2021, 6:12pm UTC](https://discuss.elastic.co/t/calculation-of-average/269325/2 "2021-04-07T18:12:06Z")

</div>

I believe the best course of action is to make an additional scripted field for each document that is Duration / Number of Attempts, then create your Metric and use the average of that field.

---

<div class="post-metadata">

**Author:** ![vivekshukla](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@vivekshukla](https://discuss.elastic.co/u/vivekshukla)\
**Post date:** [April 9, 2021, 11:23am UTC](https://discuss.elastic.co/t/calculation-of-average/269325/3 "2021-04-09T11:23:36Z")

</div>

Such a simple and elegant approach. Thank you so much!

---

<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 7, 2021, 11:24am UTC](https://discuss.elastic.co/t/calculation-of-average/269325/4 "2021-05-07T11:24:16Z")

</div>

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