# Rate 's average?

**URL:** <https://discuss.elastic.co/t/rate-s-average/162126>\
**Category:** Kibana\
**Created:** [December 26, 2018, 10:27am UTC](https://discuss.elastic.co/t/rate-s-average/162126 "2018-12-26T10:27:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Icz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icz/32/39176_2.png) [@Icz](https://discuss.elastic.co/u/Icz)\
**Post date:** [December 26, 2018, 10:28am UTC](https://discuss.elastic.co/t/rate-s-average/162126/1 "2018-12-26T10:28:00Z")

</div>

Hello,

I've two lines registered in ES :  
id - A - B - C  
1 - 100 - 0 - 0  
2 - 10 - 5 - 5

This is calculate the rate (A - B) / (B) :  
1 =\> (100 - 0) / 100 = 1  
2 =\> (10-5) / 10 = 0.5

With kibana, I can't calculate the average of this global rate...

If I use metric, I just got 0.75 ((1.00+0.5) /2) but the **result I expect is 0.9545** explained like this :  
(sum(A) - sum(B) ) / sum(A) = (110 - 5) / (110) = 0.9545

**How can I get the result I expect with metrics ?**  
Thx a lot for the help !

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [December 26, 2018, 3:24pm UTC](https://discuss.elastic.co/t/rate-s-average/162126/2 "2018-12-26T15:24:27Z")

</div>

You can use [scritped fields](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) to create a field that is computed at query time.

---

<div class="post-metadata">

**Author:** ![Icz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icz/32/39176_2.png) [@Icz](https://discuss.elastic.co/u/Icz)\
**Post date:** [December 26, 2018, 3:39pm UTC](https://discuss.elastic.co/t/rate-s-average/162126/3 "2018-12-26T15:39:15Z")

</div>

Hey Nathan,

I already try, I've created one scripted field to calculate my rate but it always calculate line by line rate, not a total rate. I've always have 0.75 rate instead of my 0.9545 expected.

I've found this [https://github.com/ommsolutions/kibana\_ext\_metrics\_vis](https://github.com/ommsolutions/kibana_ext_metrics_vis) . With this plugin I can calculate my rate but I'had to change my kibana version (downgrade to 5.6.5) and the rate seems can't be displayed on other visualizations like chart 😕

---

<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:** [January 23, 2019, 3:39pm UTC](https://discuss.elastic.co/t/rate-s-average/162126/4 "2019-01-23T15:39:16Z")

</div>

Closed on January 23, 2019, 3:39pm UTC

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