# How to get Percentage from count of records

**URL:** <https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902>\
**Category:** Kibana\
**Tags:** visualisation\
**Created:** [February 22, 2024, 5:04pm UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902 "2024-02-22T17:04:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)\
**Post date:** [February 22, 2024, 5:04pm UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/1 "2024-02-22T17:04:56Z")

</div>

Hi there,

I'm using Elastic and kibana v7.17, and I want to get the percentage from each term in my table. look at this picture below  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/0/b02a3ab652e9b08d0e650275ddf8cdd3d72fd97b.png)  
as you can see there are many counts of records of each term on the right side, how if I want to change that to become a percentage? so the formula will look like this (count of record of each term / count of record of all logs in that timerange)

is that possible to do that using a formula in the lens? if yes, how to do it? since the count function didn't accept any field inside it.

I already tried using a formula like this but it gives me 100% from all terms while I calculate manually it shouldn't get 100%

```auto
count(kql='ip_mask:*')/ count()

```

Thank you

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [February 22, 2024, 6:51pm UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/2 "2024-02-22T18:51:44Z")

</div>

Hi ,

Maybe this article could help you:  
`https://www.elastic.co/blog/how-to-display-data-as-a-percentage-in-kibana-visualizations`

Best

---

<div class="post-metadata">

**Author:** ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)\
**Post date:** [February 23, 2024, 1:21am UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/3 "2024-02-23T01:21:41Z")

</div>

Hi Alex,

I already tried TSVB too. Since i only took count of records from each term, i don't know what should i write in the numerator part. After i group the data by field, it also gives me 100% while the actual data doesn't reach 100. I tried to use pie also. It can show the percentage but not suitable if I want to show the top 50. That's why I moved to a table visualization. Do you have any other ideas?

Thanks

Pada tanggal Jum, 23 Feb 2024 02.01, Alex Salgado via Discuss the Elastic Stack \<[notifications@elastic.discoursemail.com](mailto:notifications@elastic.discoursemail.com)\> menulis:

---

<div class="post-metadata">

**Author:** ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)\
**Post date:** [February 23, 2024, 3:13am UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/4 "2024-02-23T03:13:25Z")

</div>

I found the formula. it's using overall\_sum function

```auto
count() / overall_sum(count())

```

and then I add one more count metric to sort the data in descending

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [February 23, 2024, 2:00pm UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/5 "2024-02-23T14:00:36Z")

</div>

Awesome! Is it working now?

---

<div class="post-metadata">

**Author:** ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)\
**Post date:** [February 27, 2024, 6:57am UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/6 "2024-02-27T06:57:00Z")

</div>

yes, now I'm able to create a table visualization with a percentage in it

---

<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:** [March 26, 2024, 6:57am UTC](https://discuss.elastic.co/t/how-to-get-percentage-from-count-of-records/353902/7 "2024-03-26T06:57:12Z")

</div>

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