# How to calculate a percentage value on column

**URL:** <https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765>\
**Category:** Kibana\
**Created:** [June 9, 2022, 7:28am UTC](https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765 "2022-06-09T07:28:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ely\_96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ely_96/32/103816_2.png) [@Ely\_96](https://discuss.elastic.co/u/Ely_96)\
**Post date:** [June 9, 2022, 7:28am UTC](https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765/1 "2022-06-09T07:28:13Z")

</div>

Hi all,

I need an help in order to calculate a percentage value inside a column.  
I'm using Kibana 7.16.2 and I have a table with Lens:  
1st column: item name ("Alpha", "Beta", "Gamma"....)  
from 2nd column to N column a date: sum of purchases ("2020-01-01", "2020-02-01", "2020-03-01"....).

 ![screen_kibana](https://us1.discourse-cdn.com/elastic/original/3X/4/5/455b11292fb13a52217d2c0763ab3aa418616ef5.png)

As you can see in my screen:  
value A =\> It's ok!  
value B =\> It's ok!  
value C =\> I would like to see A / B, so 49/144 = 34.03%, not 2.04%  
value D =\> always 100% (not 18.12%)

Now, about the calculation for C I have:  
`unique_count(item_name) / unique_count()`

But I think my formula should be something like:  
`unique_count(item_name) / unique_count(sum_previous_column)`

Could you please give me any suggestion?

Thanks in advance  
Ely

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [June 28, 2022, 11:18am UTC](https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765/2 "2022-06-28T11:18:16Z")

</div>

You are looking for the `overall_sum` function in Lens

 ![2022-06-28-13-16-33-screenshot](https://us1.discourse-cdn.com/elastic/original/3X/8/4/8435d8530da71a7e79aabfdbac382d945482f639.png)

With the flights sample dataset, a table with carriers as rows and columns per date interval for count and percentage of count. Showing the definition of the percentage column:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2e2f365c99eecc8270611d1d69c81d88051434f8.png)

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [June 28, 2022, 11:33am UTC](https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765/3 "2022-06-28T11:33:27Z")

</div>

Sorry my bad, the `overall_sum` function, as you probably already know, works over the **row** of the group, not over the **column** of each date bucket.

I can't figure out how to get the sum for the column to be applied in the formula ☹

@flash1293 any idea on how to sum the values on a column to get a percentage as defined by OP?

---

<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 26, 2022, 11:33am UTC](https://discuss.elastic.co/t/how-to-calculate-a-percentage-value-on-column/306765/4 "2022-07-26T11:33:44Z")

</div>

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