# Calculate number of occurrences of an event and then get total percentage out of whole

**URL:** <https://discuss.elastic.co/t/calculate-number-of-occurrences-of-an-event-and-then-get-total-percentage-out-of-whole/198903>\
**Category:** Kibana\
**Created:** [September 10, 2019, 1:05pm UTC](https://discuss.elastic.co/t/calculate-number-of-occurrences-of-an-event-and-then-get-total-percentage-out-of-whole/198903 "2019-09-10T13:05:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parmeet\_devops](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parmeet_devops/32/53918_2.png) [@parmeet\_devops](https://discuss.elastic.co/u/parmeet_devops)\
**Post date:** [September 10, 2019, 1:05pm UTC](https://discuss.elastic.co/t/calculate-number-of-occurrences-of-an-event-and-then-get-total-percentage-out-of-whole/198903/1 "2019-09-10T13:05:22Z")

</div>

I am trying to calculate the total number of occurrence of an metric (Which I am able to visualize) and then I want to calculate the percentage of occurrence out of total requests.

For example:  
I have a metric ABC\_Code which has many outputs (0,1,2,300,400....)  
I want to calculate the ABC\_Code:300 and then calculate its percentage by dividing it by total number (ABC\_Code:"1" + ABC\_Code:"2" + ABC\_Code:"300" + ABC\_Code:"400" +.....ABC\_Code:"n")

I have tried following link but it didn't helped:

> [@Doing Math over count of events](https://discuss.elastic.co/t/doing-math-over-count-of-events/97278/3):
>
> Thanks Lee for the nice explanation, but for me it doesnt work. In my case the TransationStatus field is text based and i want to calculate what was the percentage of Successful transaction out of total. SuccessRate= Round(SUCCESS/(SUCCESS + FAILURE)\*100 , 2) The method you mentioned doesnt work for me. It is always showing 0.

Kindly not that the values I am interested are very small (e.g. 10/10000000) and I want to display it as percentage.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [September 12, 2019, 5:04pm UTC](https://discuss.elastic.co/t/calculate-number-of-occurrences-of-an-event-and-then-get-total-percentage-out-of-whole/198903/2 "2019-09-12T17:04:46Z")

</div>

I don't believe you can do that with any of the built-in visualizations in Kibana (see [https://github.com/elastic/kibana/issues/2646](https://github.com/elastic/kibana/issues/2646)). However you may be able to do this using Canvas. Do you have access to Canvas?

---

<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:** [October 10, 2019, 5:04pm UTC](https://discuss.elastic.co/t/calculate-number-of-occurrences-of-an-event-and-then-get-total-percentage-out-of-whole/198903/3 "2019-10-10T17:04:47Z")

</div>

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