# How to compare the sums of multiple columns?

**URL:** https://discuss.elastic.co/t/how-to-compare-the-sums-of-multiple-columns/268491
**Category:** Kibana
**Created:** [March 26, 2021, 12:23pm UTC](https://discuss.elastic.co/t/how-to-compare-the-sums-of-multiple-columns/268491 "2021-03-26T12:23:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![saintjohn](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@saintjohn](https://discuss.elastic.co/u/saintjohn)
#### Post date: [March 26, 2021, 12:23pm UTC](https://discuss.elastic.co/t/how-to-compare-the-sums-of-multiple-columns/268491/1 "2021-03-26T12:23:28Z")

</div>

Hi,

I have datasets like below.  
{  
`count_A`: 10,  
`count_B`: 5  
}  
{  
`count_A`: 20,  
`count_`: 5  
}

I would to create a Kibana pie chart that compares the sums of each columns.  
In this case, 30 vs 10 for count\_A and count\_B like below.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/4/e4053bb4ce4e195e804cec29a5ab0138c7ead00e.png)

May I know how I can realize this?

Regards,

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 27, 2021, 12:08am UTC](https://discuss.elastic.co/t/how-to-compare-the-sums-of-multiple-columns/268491/2 "2021-03-27T00:08:54Z")

</div>

It would probably make more sense to do this as a bar chart. Kibana pie charts let you pick a way to aggregate the data and the metric to show for the aggregations. You are looking at all the data as one aggregate and want to get the sum of 2 different fields in the data.

In a vertical bar chart, you can have multiple horizontal axes. You can make a bar chart where one axis is the sum of `count_A` and another axis is the sum of `count_B`. Here is a screenshot of how to set that up in Lens:

 ![Screenshot from 2021-03-26 17-05-55](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d793f09f2fbf896680dcda331368b71a7c9556ef.png)

You can leave the "Horizontal axis" option blank to view all the data as one aggregate. Then select 2 different vertical axes as "sum" of the fields you want to see.

---

<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: [April 24, 2021, 12:09am UTC](https://discuss.elastic.co/t/how-to-compare-the-sums-of-multiple-columns/268491/3 "2021-04-24T00:09:34Z")

</div>

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