# Issue while plotting percentage in Kibana

**URL:** <https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855>\
**Category:** Kibana\
**Created:** [December 8, 2017, 2:00pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855 "2017-12-08T14:00:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratik\_Kagda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pratik_kagda/32/66397_2.png) [@Pratik\_Kagda](https://discuss.elastic.co/u/Pratik_Kagda)\
**Post date:** [December 8, 2017, 2:00pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855/1 "2017-12-08T14:00:20Z")

</div>

Hello,

I got stucked at one place and need your help to display data into visulizaiton.

Here is my sample document:

{  
"@timestamp": 1512606017619,  
"id": "2odalecgvg9f58vdm8e6vgoc2p",  
"scenario": "Test scenario",  
"scenarioDetails": "3300AB8D178C130D --\> CE0617169CAE2F02017E",  
"Value A" : 1,  
"Value B" : 2,  
"Value C" : 3,  
"Value D" : 4  
}

Now I need to display percentage for each scenario into graph i.e.

Percentage(%) = (TotalCount(Value A) / TotalCount(Value B))\*100

I tried a lot but coudn't able to plot it into any visualization.

Please help me to sort this out.

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [December 8, 2017, 6:01pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855/2 "2017-12-08T18:01:02Z")

</div>

Hi there,

When you do something like `TotalCount(ValueA)` I'm assuming you're aggregating all of the `ValueA` values for the documents within a certain time range. To transform that value we'd need to run some kind of script on it. Unfortunately, we don't currently support scripts for aggregations. See [Scripted field on Aggregated value](https://discuss.elastic.co/t/scripted-field-on-aggregated-value/87157/2) for a similar question.

I'm a little confused by your question though, because it seems like the Percentage result you're looking for would be a single value for a given time range, and not a value which changes over time. How were you planning on plotting this on a chart? What would you like your X-Axis to be?

Thanks,  
CJ

---

<div class="post-metadata">

**Author:** ![Pratik\_Kagda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pratik_kagda/32/66397_2.png) [@Pratik\_Kagda](https://discuss.elastic.co/u/Pratik_Kagda)\
**Post date:** [December 8, 2017, 6:57pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855/3 "2017-12-08T18:57:34Z")

</div>

Hello,

I really appreciate for your prompt reply. Well my requirement is I need to calculate percentage from logged data and plot it into chart. Here I am facing couple of concern like which type of charting I should use as mostly all charts aggregate function and which is preventing me to select field. Second major thing is using scripting I can calculate percentage but neither I able to save that script nor I can create chart from that script.

Here I have attached a sample image which illustrate scenario. Is it possible to achieve using Kibana visualization?

![Sample Chart](https://us1.discourse-cdn.com/elastic/original/3X/1/4/14943bbd913b29e4796d29a49ecc9100fa209e55.png)

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [December 8, 2017, 9:03pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855/4 "2017-12-08T21:03:13Z")

</div>

Ah of course! That image clears things up for me and now I feel a bit silly I didn't think of that originally. The Horizontal Bar Chart visualization will let you create a chart like this. But Kibana is currently limited to visualizing certain types of buckets, e.g. terms or a date histogram. We need to add functionality support bucketing with scripts before this exact chart can be built.

CJ

---

<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 5, 2018, 9:03pm UTC](https://discuss.elastic.co/t/issue-while-plotting-percentage-in-kibana/110855/5 "2018-01-05T21:03:32Z")

</div>

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