# Use pie-chart visualization for displaying most/least used records

**URL:** <https://forum.opensearch.org/t/use-pie-chart-visualization-for-displaying-most-least-used-records/15480>\
**Category:** OpenSearch Dashboards\
**Created:** [August 9, 2023, 7:49am UTC](https://forum.opensearch.org/t/use-pie-chart-visualization-for-displaying-most-least-used-records/15480 "2023-08-09T07:49:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ciuline](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@ciuline](https://forum.opensearch.org/u/ciuline)\
**Post date:** [August 9, 2023, 7:49am UTC](https://forum.opensearch.org/t/use-pie-chart-visualization-for-displaying-most-least-used-records/15480/1 "2023-08-09T07:49:25Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
Opensearch version - 2.5.0  
Server OS - CentOS 8  
Browser - Chrome/Firefox

**Describe the issue** :  
Hello everyone,  
I am trying to create some pie-chart visualizations which can display the top 10 most used and top 10 least used permission from my permission index. Is there any way to achieve this?  
I tried setting the “Order” to “Ascending/Descending” and the “Size” parameter to 10, but it is pretty obvious that not all records are counted before doing the sort, which leads to erronous results.  
You can see in the screenshots that, for the permission “Validate the deletion of an Organization”, I initially get a count of 6 records but the correct value should be 90 (which becomes obvious when I filter ony on this permission).  
Any ideas are greatly appreciated.

**Configuration** :

**Relevant Logs or Screenshots** :

 ![Piechart](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/3f0a6e10b8c78a837da413d1d484406b98c09b76.png)

---

<div class="post-metadata">

**Author:** ![AMoo-Miki](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/amoo-miki/32/4642_2.png) [@AMoo-Miki](https://forum.opensearch.org/u/AMoo-Miki)\
**Post date:** [August 10, 2023, 7:06am UTC](https://forum.opensearch.org/t/use-pie-chart-visualization-for-displaying-most-least-used-records/15480/2 "2023-08-10T07:06:06Z")

</div>

The date range impacts the data you see. So if the date is set to Last Week, it will show you the most used and least used ones within the last week. Do you think that would explain the unexpected results?

[This is pie chart I made](https://playground.opensearch.org/app/visualize#/create?type=pie&savedSearchId=571aaf70-4c88-11e8-b3d7-01146121b73d&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-1h,to:now))&_a=(filters:!(),linked:!t,query:(language:kuery,query:''),uiState:(),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(field:DestCityName,missingBucket:!f,missingBucketLabel:Missing,order:desc,orderBy:'1',otherBucket:!f,otherBucketLabel:Other,size:10),schema:segment,type:terms)),params:(addLegend:!t,addTooltip:!t,isDonut:!t,labels:(last_level:!t,show:!f,truncate:100,values:!t),legendPosition:right,row:!f,type:pie),title:'',type:pie))) on the Playground. If you change the date filter to Last 15 minutes or even 30, you would see that it doesn’t even return 10 results.

---

<div class="post-metadata">

**Author:** ![ciuline](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@ciuline](https://forum.opensearch.org/u/ciuline)\
**Post date:** [August 10, 2023, 7:31am UTC](https://forum.opensearch.org/t/use-pie-chart-visualization-for-displaying-most-least-used-records/15480/3 "2023-08-10T07:31:24Z")

</div>

Hi @AMoo-Miki .  
Thanks for your reply. I am not sure that the date range has any impact on my results as I have kept the same range for both tests.  
However, I have seen something strange when I run the query of the pie-chart in dev-tools. You can see in the screenshot below that the value of doc\_count\_error\_upper\_bound is -1 for my example. On the Playground environment, the value is 0, so maybe this is related to the difference I am seeing in my results.

 ![doc_count](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/1/1b8b0b487d69464e7571adf28ebadf1beeb26f15.png)
