# Get Percentage of two different SUM

**URL:** <https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814>\
**Category:** Kibana\
**Created:** [December 13, 2018, 8:59pm UTC](https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814 "2018-12-13T20:59:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaulSan](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@RaulSan](https://discuss.elastic.co/u/RaulSan)\
**Post date:** [December 13, 2018, 8:59pm UTC](https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814/1 "2018-12-13T20:59:25Z")

</div>

Hi.  
I have a problem and I do not know how to solve it. I hope you can help me  
I have an index with thousands of documents. These documents have dozens of fields by which they can be filtered. In addition, one of these fields is an amount (IMP Field) and another, a field that indicates the type of document (two possible values: Type A and type B).

I need to get the percentage of the amount of type B documents in relation to the amount of type A documents.  
That is to say (SUM (IMP of type B) / SUM (IMP of type A)) \* 100  
For example:  
---------------------TYPE ----------- IMP  
Document 1----- A -------------15  
Document 2 ---- A -------------25  
Document 3 ---- B ------------- 7  
Document 4---- B ------------- 2  
Document 5 ---- B ------------- 1

The percentage I want to obtain is:

SUM (IMP of type B) / SUM (IMP of type A)) \* 100  
(10/40) \* 100 = 25%

What kind of graph can I use? how?

I think that the ideal graphics for this case are Gauge and Goal with the defined range of 0 to SUM (IMP of type A) .. but it is not possible to use dynamic ranges.

Thank you

---

<div class="post-metadata">

**Author:** ![RaulSan](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@RaulSan](https://discuss.elastic.co/u/RaulSan)\
**Post date:** [December 18, 2018, 9:52am UTC](https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814/2 "2018-12-18T09:52:42Z")

</div>

nobody can help me?

---

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [December 19, 2018, 2:56am UTC](https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814/3 "2018-12-19T02:56:12Z")

</div>

Make a pie chart and select the SUM metric on the IMP field. Then under bucket select term and pick TYPE as the field.

That should give the the percentage of A/B based on the total of IMP.

To get the percentage of SUM A and SUM B, maybe you can do that with a scripted field? I don't think there is a visualization that can do what you want out of the box.

---

<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 16, 2019, 2:56am UTC](https://discuss.elastic.co/t/get-percentage-of-two-different-sum/160814/4 "2019-01-16T02:56:14Z")

</div>

Closed on January 16, 2019, 2:56am UTC

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