Monthly Bar Graph Postgresql DB

Grafana 9.1.6

I’m trying to get a bar graph that would display my energy consumption per month.
Any help would be greatly appreciated.


2 Likes

Please share your query that was used to generate this data.

oh ya sorry because i’m new user, grafana limits my embedded attach file
here’s my query

Can you click the pencil icon and paste the text of the query here (not a screenshot)?

SELECT
$__unixEpochGroupAlias(time,1h),
stddev(“E_CC01”) AS “E_CC01”
FROM “Energy_CC”
GROUP BY 1
ORDER BY 1

You are grouping by 1h = 1hour. You need to group it by 1 month

here’s the result if im change by 1 month

i want the result is in x axis display the month (Jan, Feb, Mar,…,Dec) or in graph they are show 12 bars it’s represent of month

Do you have 12 months worth of data in that table?

What if the data spans from June 2022 to June 2023 how should the months be displayed?

Try this instead

TO_CHAR(time, 'Mon') 

my database is running about 3 days

just changed the label of bar

what data type is the time column in Energy_CC table?
please post the DDL/Schema/Create table of Energy_CC

image

that is automatically generated from my scada software

that looks like nanoseconds or milliseconds?

try

select to_timestamp(time/1000);

and this is when i’m applying in grafana

1 Like

thank you for your help, but what if my data is collected let’s say 2 years, will it later show 24 bars representing of 2 years?

Sorry yesterday I have exceeded the reply limit

here’ the results

where does the data come from?
i want to find the difference from the value of each month in E_CC01

Let’s assume I already have data spanning 2 years

SELECT
  TO_CHAR(to_timestamp(date), 'Mon-YY'),
  stddev("E_CC")
FROM "Energy_CC"
GROUP BY 1
ORDER BY 1

how to sort from jan to dec

1 Like

yes, but I still don’t understand