# How to show a count of status=X percentage from the total statuses

**URL:** <https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578>\
**Category:** Kibana\
**Created:** [June 6, 2019, 12:10pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578 "2019-06-06T12:10:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorj1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorj1234/32/21339_2.png) [@dorj1234](https://discuss.elastic.co/u/dorj1234)\
**Post date:** [June 6, 2019, 12:10pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/1 "2019-06-06T12:10:15Z")

</div>

Hello,  
Hoping to find help to a simple % calculation. [This guy](https://discuss.elastic.co/t/how-to-show-total-count-and-percentage-of-error-records-in-a-table/134918/3) received little response but I hope there is a way.

I have a record that contains status=X. I also have the total count of statuses.  
My goal is to find the percentage count where X appeared.  
For example if count status=X is 35, and I have a total of 100 statuses I want to show:  
count(status=X) / count(all statuses) as a metric.

I thought about using a metric showing my status=X and then json input like this:

```auto
{
"script": "_value / ______"
}

```

How can I access the total count like this?  
Thanks in advance for any advice.

JD

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [June 6, 2019, 7:58pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/2 "2019-06-06T19:58:30Z")

</div>

I don't think there's a way to do what you are looking for using painless scripts, as those only run scripts based on an individual document's values, not aggregated values. [Bucket script aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html) are probably what you're looking for here, but unfortunately those are not (yet) supported in Kibana.

If you'd like, you could follow along with progress on the [Github issue](https://github.com/elastic/kibana/issues/4707). It has been an ongoing discussion when and how we could introduce support for it; so that will probably be the best place to look for updates (or to show your support with a 👍)

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [June 6, 2019, 8:02pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/3 "2019-06-06T20:02:06Z")

</div>

I should also note that depending on how you are need to visualize this, you may be able to accomplish what you are looking for in Timelion, which supports [some mathematical functions](https://www.elastic.co/guide/en/kibana/current/timelion-math.html).

---

<div class="post-metadata">

**Author:** ![dorj1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorj1234/32/21339_2.png) [@dorj1234](https://discuss.elastic.co/u/dorj1234)\
**Post date:** [June 8, 2019, 12:04pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/4 "2019-06-08T12:04:16Z")

</div>

you say the script runs on individual documents, which may not be accurate, since when looking at "last 15 minutes" I can have a single metric displayed that counts all of the documents with their statuses, therefore I can see all of them within this metric's view. Question is - can I access any functions that aggregate them to show % ..  
Metric shows count=100, within the past 15 minutes, and I want to count some of them. Frustrating that it's so simple yet may not be doable.

I'll try your other suggestion with timelion maybe .. thank you!

---

<div class="post-metadata">

**Author:** ![dorj1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorj1234/32/21339_2.png) [@dorj1234](https://discuss.elastic.co/u/dorj1234)\
**Post date:** [June 11, 2019, 4:22pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/5 "2019-06-11T16:22:08Z")

</div>

One more thought - if I used a pie visual, it would automagically show me the spread of all of my statuses, all I need is to show this in a table format using Kibana, the way it does the same thing in a pie.

---

<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:** [July 9, 2019, 4:22pm UTC](https://discuss.elastic.co/t/how-to-show-a-count-of-status-x-percentage-from-the-total-statuses/184578/6 "2019-07-09T16:22:13Z")

</div>

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