# How to get count in percentage in data table of kibana

**URL:** <https://discuss.elastic.co/t/how-to-get-count-in-percentage-in-data-table-of-kibana/137000>\
**Category:** Kibana\
**Created:** [June 22, 2018, 9:24am UTC](https://discuss.elastic.co/t/how-to-get-count-in-percentage-in-data-table-of-kibana/137000 "2018-06-22T09:24:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sushmahp](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@sushmahp](https://discuss.elastic.co/u/sushmahp)\
**Post date:** [June 22, 2018, 9:24am UTC](https://discuss.elastic.co/t/how-to-get-count-in-percentage-in-data-table-of-kibana/137000/1 "2018-06-22T09:24:37Z")

</div>

hi,  
i have data of this format.  
{  
"make": "LG",  
"model":Model1,  
"serialNo":"1801MBX11002",  
"IP":"24.160.207.7",  
"prevChannelName":"starPlus",  
"prevTunedTime":"2018-05-28 16:24:05",  
"prevEventName":"Siya ke ram",  
"curChannelName":"StarMovie",  
"curTunedTime":"2018-05-28 17:24:05",  
"curEventName":"Race To Witch Mountain"  
}

the usecase for above data is  
percentage of unique users viewed a particular event for specified time.  
i have to create report for above usecase in data table of kibana  
so my problem is  
i am not able to get unique count of users in percentage in data table.  
so if anyone knows how to do it please help me out..

thanks

---

<div class="post-metadata">

**Author:** ![christophilus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophilus/32/42991_2.png) [@christophilus](https://discuss.elastic.co/u/christophilus)\
**Post date:** [July 9, 2018, 2:04pm UTC](https://discuss.elastic.co/t/how-to-get-count-in-percentage-in-data-table-of-kibana/137000/2 "2018-07-09T14:04:44Z")

</div>

So, you need to ask yourself a few questions:

- How is a unique user identified? Is it just the serialNo? Is it a combination of fields?

If it's a single field, you can count unique values fairly simply if it's a combination of fields, you'll need to do a scripted query as described here:

> **[Terms aggregation | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-script)**

Once you have a query that gives you a count of the distinct values, you can display an aggregate. Here's a question and answer about how to display a percentage.

> [@Gauge with dynamic maximum value](https://discuss.elastic.co/t/gauge-with-dynamic-maximum-value/130634/2):
>
> Hi Michael, You should be able to do this using the Time Series Visual Builder. If you choose "gauge", then "panel options", you can specify "1" as your max value. Then in your gauge data settings, you can compute the dynamic ratio per table. Here's a screenshot of a similar setup: Hope that helps!

One last note: it may be easier to massage your data so that it's stored in a way that makes the Kibana queries easier to write and reason about.

---

<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:** [August 6, 2018, 2:04pm UTC](https://discuss.elastic.co/t/how-to-get-count-in-percentage-in-data-table-of-kibana/137000/3 "2018-08-06T14:04:45Z")

</div>

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