# Grafana Pie Chart usage

**URL:** <https://community.grafana.com/t/grafana-pie-chart-usage/17620>\
**Category:** Grafana\
**Created:** [May 23, 2019, 6:45pm UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620 "2019-05-23T18:45:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharma77](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@dharma77](https://community.grafana.com/u/dharma77)\
**Post date:** [May 23, 2019, 6:45pm UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/1 "2019-05-23T18:45:49Z")

</div>

Hi,

I am new using Grafana. I need to create a pie chart in Grafana from a postgreSQL datasource.

My table has the structure (time, user, count), and I would like to represent the maximum number of count per user, so I would need to have one section of the pie per user. Is that possible?

I have already read this topic regarding the pie chart:

> [@Pie Chart Plugin Example?](https://community.grafana.com/t/pie-chart-plugin-example/9068):
>
> Hi all. I’m using Grafana 5.2.1 and Microsoft SQL server. The pie chart plugin 1.3.3? is installed on my instance of Grafana, and I can open a new pie chart on the dashboard. I can’t figure out how do make a pie chart work. I understand it’s a time series, but don’t know how to get it running. I have a bunch of counts (int) that I want to display, but was hoping someone had an example of a functioning pie chart that I could model mine after. Thanks in advance!

but I couldn’t manage to get the desired result.

I have tried:  
SELECT  
now() as time,  
MAX(count)  
FROM  
shema.table  
GROUP BY user

But I only get all the pie in the same section with the value of the max count for all user, not the maximum per user.

Thanks in advance!! 🙂

---

<div class="post-metadata">

**Author:** ![danielgonzalez](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/danielgonzalez/32/7125_2.png) [@danielgonzalez](https://community.grafana.com/u/danielgonzalez)\
**Post date:** [May 23, 2019, 8:02pm UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/2 "2019-05-23T20:02:17Z")

</div>

Hi Dharma77,  
This is related with postgres, not to grafana.  
Can solved it in the following way:

```auto
SELECT
now() as time,
MAX(count) as value, 
user as metric
FROM
shema.table
GROUP BY user

```

---

<div class="post-metadata">

**Author:** ![dharma77](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@dharma77](https://community.grafana.com/u/dharma77)\
**Post date:** [May 24, 2019, 7:03am UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/3 "2019-05-24T07:03:17Z")

</div>

Thanks! Problem solved 😃

---

<div class="post-metadata">

**Author:** ![busterwang](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@busterwang](https://community.grafana.com/u/busterwang)\
**Post date:** [June 11, 2021, 6:40am UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/4 "2021-06-11T06:40:15Z")

</div>

Hello, I have some problems with the pie chart. I use v7.5.5, and then use the following statements:

```auto
SELECT
  now() as time,
  principal as metric,
  count(1) as value
FROM jhi_persistent_audit_event
GROUP BY principal

```

The **results** are as follows:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/1/1/111a07ee193b1cd3545df2547f0fafe236d815ab.png)

The tag name of the pie chart I want to display is the value of metric, such as admin, but the tag name it displays is not what I want to display. As shown in the figure below:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/c/e/cebe6b4fe6ecad7a7245c5a4ae996c86b0fc1507.png)

What did I do wrong?How can I modify it

---

<div class="post-metadata">

**Author:** ![danielgonzalez](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/danielgonzalez/32/7125_2.png) [@danielgonzalez](https://community.grafana.com/u/danielgonzalez)\
**Post date:** [June 12, 2021, 8:10pm UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/5 "2021-06-12T20:10:39Z")

</div>

What grafana version are you using?

---

<div class="post-metadata">

**Author:** ![busterwang](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@busterwang](https://community.grafana.com/u/busterwang)\
**Post date:** [June 16, 2021, 7:17am UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/6 "2021-06-16T07:17:42Z")

</div>

The version I used was 7.5.5, and I later tried to use 8.0.2, but the new version didn’t have this problem

---

<div class="post-metadata">

**Author:** ![pranjaljadhav](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@pranjaljadhav](https://community.grafana.com/u/pranjaljadhav)\
**Post date:** [July 8, 2021, 8:19am UTC](https://community.grafana.com/t/grafana-pie-chart-usage/17620/7 "2021-07-08T08:19:01Z")

</div>

Hey!  
how do I create the pie chart without using now() as time.  
I have a timestamp field which I want to use as time.  
For eg if the value in timestamp field is 5/11/2021 it should count the values ahead of the date 5/11/2021.
