# Percentage breakdown for each subgroup

**URL:** <https://discuss.elastic.co/t/percentage-breakdown-for-each-subgroup/376750>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [April 3, 2025, 2:51pm UTC](https://discuss.elastic.co/t/percentage-breakdown-for-each-subgroup/376750 "2025-04-03T14:51:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mat-bro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mat-bro/32/134778_2.png) [@mat-bro](https://discuss.elastic.co/u/mat-bro)\
**Post date:** [April 3, 2025, 2:51pm UTC](https://discuss.elastic.co/t/percentage-breakdown-for-each-subgroup/376750/1 "2025-04-03T14:51:47Z")

</div>

Hi,

I am trying to create a table in Kibana Lens (8.13) to calculate statistics for some products. In particular, for each month and product type, I would need to calculate the number of products considered and the percentage breakdown for each month (i.e. the sum of all percentages for that specific month must add up to 100).  
The problem arises on this last statistic: I have tried using the formula `count() / overall_sum(count())` However, `overall_sum` sums all products in that specific category for all the months. for instance:

ACTUAL  
date | product\_type | count() | count() / overall\_suim(count())  
2025-01-01 1 | 6 | 33%  
2025-01-01 2 | 7 | 70%  
2025-01-01 3 | 8 | 50%  
2025-02-01 1 | 12 | 67%  
2025-02-01 2 | 3 | 30%  
2025-02-01 3 | 8 | 50%

EXPECTED  
date | product\_type | count | count() / overall\_suim(count())  
2025-01-01 1 | 6 | 29%  
2025-01-01 2 | 7 | 33%  
2025-01-01 3 | 8 | 38%  
2025-02-01 1 | 12 | 52%  
2025-02-01 2 | 3 | 13%  
2025-02-01 3 | 8 | 35%

As you can see, for each month, the sum of the percentages is equal to 100%.  
Is there a way to get these results?  
Thank you,

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [April 3, 2025, 3:39pm UTC](https://discuss.elastic.co/t/percentage-breakdown-for-each-subgroup/376750/2 "2025-04-03T15:39:49Z")

</div>

Hi @mat-bro

you can track this feature request which seems similar to what you need: [[Lens] make total document count available in formula · Issue #160562 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/160562)

Another option would be to upgrade and use an ES|QL to build the right table to use for the visualization.

---

<div class="post-metadata">

**Author:** ![mat-bro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mat-bro/32/134778_2.png) [@mat-bro](https://discuss.elastic.co/u/mat-bro)\
**Post date:** [April 3, 2025, 4:01pm UTC](https://discuss.elastic.co/t/percentage-breakdown-for-each-subgroup/376750/3 "2025-04-03T16:01:32Z")

</div>

> [@Marco\_Liberati](#):
>
> Another option would be to upgrade and use an ES|QL to build the right table to use for the visualization.

Hi Marco,

Thank you for your reply. In the link you shared I saw a reference to another issue that corresponds exactly to my problem ([https://github.com/elastic/kibana/issues/174510](https://github.com/elastic/kibana/issues/174510)). However, it was closed as not planned.  
I will try to see if it is possible to run this table with ES|QL.  
Thank you!
