# Graphs for Month

**URL:** <https://community.grafana.com/t/graphs-for-month/47728>\
**Category:** Grafana\
**Created:** [May 18, 2021, 4:54pm UTC](https://community.grafana.com/t/graphs-for-month/47728 "2021-05-18T16:54:42Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 18, 2021, 4:54pm UTC](https://community.grafana.com/t/graphs-for-month/47728/1 "2021-05-18T16:54:42Z")

</div>

Hi to all.  
I’ve a table in this format:  
datetime | energy  
I’d like to create a graph that represents the energy by months, so in the x-axis  
January, February, March, April, etc.  
And for each month a serie for each year, showing the sum of energy for that month and that year, to compare the energy each month in all years.

I’m thinking it’s not possibile in grafana…  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Nefariis](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@Nefariis](https://community.grafana.com/u/Nefariis)\
**Post date:** [May 18, 2021, 8:17pm UTC](https://community.grafana.com/t/graphs-for-month/47728/2 "2021-05-18T20:17:03Z")

</div>

A few simple questions - What database are you using? and is Grafana currently connected to the database with a working connection?

Grafana can group time series by any range of time using the `Group By` feature (depending on data source)

---

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 19, 2021, 3:47am UTC](https://community.grafana.com/t/graphs-for-month/47728/3 "2021-05-19T03:47:26Z")

</div>

I’m using Mysql.  
The group by feature works for tables, but not for graphs.  
If I change db, changes the behavior of grafana? (sorry I’m learning grafana since few weeks…)  
thanks.

---

<div class="post-metadata">

**Author:** ![alexsmart](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/alexsmart/32/272_2.png) [@alexsmart](https://community.grafana.com/u/alexsmart)\
**Post date:** [May 19, 2021, 4:51am UTC](https://community.grafana.com/t/graphs-for-month/47728/4 "2021-05-19T04:51:38Z")

</div>

Im using InfluxDB amd have the same problem. I have an energy counter data and want to get a monthly statistics, i.e. January power consumption = 01 Feb meter readings - 01 Jan meter readings, and so on. Still dont get how to do it

 ![01](https://us1.discourse-cdn.com/grafana/original/3X/6/7/67cc6ac6bbea14c581cadddc96ab732a8abcfb46.jpeg)

---

<div class="post-metadata">

**Author:** ![Nefariis](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@Nefariis](https://community.grafana.com/u/Nefariis)\
**Post date:** [May 19, 2021, 2:54pm UTC](https://community.grafana.com/t/graphs-for-month/47728/5 "2021-05-19T14:54:10Z")

</div>

@angeroluca - `Group By` should work for graphs as well - can you put a csv of your table somewhere online? Ill see if I can create the graph sometime today.

@alexsmart - Can you go toggle the “Text Edit Mode” for the query and post it your query here?

---

<div class="post-metadata">

**Author:** ![castillo92](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@castillo92](https://community.grafana.com/u/castillo92)\
**Post date:** [May 20, 2021, 7:51am UTC](https://community.grafana.com/t/graphs-for-month/47728/6 "2021-05-20T07:51:36Z")

</div>

> [@angeroluca](#):
>
> o create a graph that represents the energy by months, so in the x-axis  
> January, February, March, April, etc.

The first you have to know is how you store your metrics and how to explore it.

I log a few power metrics once per second. Then I create some mean metrics like mean minute and hourly means

To show month and year metrics I use the hourly mean of each day.

Are you looking for something like this?

 ![imagen](https://us1.discourse-cdn.com/grafana/original/3X/1/1/110164922b1f1c82f0dfaec40c8db282cf0b25ec.png)

**This month:**

 ![imagen](https://us1.discourse-cdn.com/grafana/original/3X/c/f/cf4853488f73e1d0dfd2af5472953c6cc0d1fd75.png)

**Previous month**

 ![imagen](https://us1.discourse-cdn.com/grafana/original/3X/f/f/ff975e8b19f4b64e191b4d26cb1a63bb80fccf89.png)

**This year**

 ![imagen](https://us1.discourse-cdn.com/grafana/original/3X/4/b/4b1288f494b298ccf877f3fb25efff897f2c6573.png)

**Previous year**

 ![imagen](https://us1.discourse-cdn.com/grafana/original/3X/8/5/85ef5870109cd3be71e5b7d6a5e18d5f1b7455bb.png)

---

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 20, 2021, 8:57am UTC](https://community.grafana.com/t/graphs-for-month/47728/7 "2021-05-20T08:57:15Z")

</div>

Thanks, you can download the CSV (with the result I would) here: [WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free](https://we.tl/t-bJYNb3xOsY)  
The columns are:  
IDImd: ID record  
IDImp: ID for the plant  
DataOra: date/time of the record  
Anno: year of datetime  
Mese: month of datetime  
Prodotta1: energy of that period

In the excel file I put the graph like I wold see in grafana, if possibile.  
Thanks for your support.

 ![impiantidati chart example](https://us1.discourse-cdn.com/grafana/original/3X/b/d/bda837f2555c5892d7607b76126c903041140747.jpeg)

---

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 20, 2021, 9:08am UTC](https://community.grafana.com/t/graphs-for-month/47728/8 "2021-05-20T09:08:00Z")

</div>

Something like that.  
Below the example with my data, grouped by month

 ![grafana example group by month](https://us1.discourse-cdn.com/grafana/original/3X/2/a/2aafe224b11e16c62f359e2800c21d0e12ed7b45.jpeg)

But I need to group all months of many years in several bars, like that:

 ![impiantidati chart example](https://us1.discourse-cdn.com/grafana/original/3X/b/d/bda837f2555c5892d7607b76126c903041140747.jpeg)

Thankyou

---

<div class="post-metadata">

**Author:** ![Nefariis](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@Nefariis](https://community.grafana.com/u/Nefariis)\
**Post date:** [May 20, 2021, 2:44pm UTC](https://community.grafana.com/t/graphs-for-month/47728/9 "2021-05-20T14:44:15Z")

</div>

uhhh… I believe you just need to use order by if you are using SQL

```auto
SELECT Prodotta1
FROM YourTable
order by Mese, Anno

```

---

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 21, 2021, 4:27pm UTC](https://community.grafana.com/t/graphs-for-month/47728/10 "2021-05-21T16:27:55Z")

</div>

Sorry but in this way I see only the table, without grouping…

---

<div class="post-metadata">

**Author:** ![Nefariis](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@Nefariis](https://community.grafana.com/u/Nefariis)\
**Post date:** [May 21, 2021, 8:00pm UTC](https://community.grafana.com/t/graphs-for-month/47728/11 "2021-05-21T20:00:50Z")

</div>

Alright with a little tinkering this morning I was able to accomplish what you wanted -

First you need to download the multistat plugin located here

> **[Multistat plugin for Grafana | Grafana Labs](https://grafana.com/grafana/plugins/michaeldmoore-multistat-panel/)**
>
> Enhanced version of built-in SingleStat panel, for queries involving multi-valued recordsets

Next you need to add a column in your data that combines the month and the year, something like “MM-YYYY”

Then you can use the query -  
`select sum("usage") from test group by newColumn`

then you set the label column to your newColumn and the value column to sum - and viola, you should have a graph that looks similar to this.

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

---

<div class="post-metadata">

**Author:** ![angeroluca](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@angeroluca](https://community.grafana.com/u/angeroluca)\
**Post date:** [May 25, 2021, 7:42am UTC](https://community.grafana.com/t/graphs-for-month/47728/12 "2021-05-25T07:42:34Z")

</div>

Great!!!  
I used that plugin, a little different from your istructions but the result is the same!

 ![graph for month-year](https://us1.discourse-cdn.com/grafana/original/3X/2/0/200f8166a124047c45b80ba300a358d58fbfb53c.jpeg)  
Thank you a lot!!

---

<div class="post-metadata">

**Author:** ![coolon04](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@coolon04](https://community.grafana.com/u/coolon04)\
**Post date:** [January 19, 2022, 8:05am UTC](https://community.grafana.com/t/graphs-for-month/47728/14 "2022-01-19T08:05:48Z")

</div>

What type of Visualisation did you use here (its not bar plot right?)

---

<div class="post-metadata">

**Author:** ![sonybuoay](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sonybuoay](https://community.grafana.com/u/sonybuoay)\
**Post date:** [January 27, 2022, 11:27am UTC](https://community.grafana.com/t/graphs-for-month/47728/15 "2022-01-27T11:27:28Z")

</div>

Hello. i am using influxdb and grafana under home assistant. i tried to create the format you propose but it is not workig for me. i have a daily total consumption that i would like to graph as yearly consumption. When i use group by 4w it will take the max value recorded in the group of 4w. if i group by 1d, the total value is correctly calculated, but the graph splits the bar in a daily view. how can i configure grafana to show me the grouped by 4w but to show me the toal value of the energy cosumed in the 4w?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [May 18, 2022, 4:54pm UTC](https://community.grafana.com/t/graphs-for-month/47728/16 "2022-05-18T16:54:47Z")

</div>

Closed on May 18, 2022, 4:54pm UTC

This topic was automatically closed after 365 days. New replies are no longer allowed.
