Help with processing consumption data for Dashboard

Hi, sorry I’m very new to grafana.

I have some consumption data coming in from InfluxDB cloud which is simply a (ever) growing value representing energy use. I’m looking to create a dashboard that can compare what was used say yesterday with today (or last week / current week) etc etc, but can’t figure out how to do it.

It would also be nice if I could aggregate the data so I can show a 7 day chart at 30min intervals.

My data looks like this

Total	time
1889	15/02/2024 00:29
1890	15/02/2024 00:30
1892	15/02/2024 00:30
1893	15/02/2024 00:30
1894	15/02/2024 00:30
1895	15/02/2024 00:30
1895	15/02/2024 00:30
1895	15/02/2024 00:30

Many thanks

Hi @mailc1d6 and welcome to the Grafana forum.

Are you using Flux or InfluxQL or SQL?

Hi, I’m using SQL

Are you recording a new reading every 30 minutes? If not, at what interval do the readings arrive?

The interval will likely be 15 minutes, but currently in the development test its set to 15 seconds.

Can you share a simple query of your data in order to get a look at what you have named your fields, measurement, etc?

For example, to compare the last (max) value from today vs yesterday, assuming your table is named readings with columns timestamp (of type timestamp ) and value (of type numeric ), perhaps something like this:

SELECT
  DATE_TRUNC('day', timestamp) AS date,
  MAX(value) AS value
FROM readings
WHERE timestamp >= DATE_TRUNC('day', CURRENT_TIMESTAMP)
GROUP BY date
ORDER BY date DESC
LIMIT 2;

Hi. Thanks

The query return is as attached (its not that complicated - yet).

Gave it a go and got this error

Error while planning query: SQL error: ParserError(“Expected end of statement, found: DATE_TRUNC”): rpc error: code = InvalidArgument desc = Error while planning query: SQL error: ParserError(“Expected end of statement, found: DATE_TRUNC”)

Lets also see your query not just the error produced by the query

Hi. Have decided to move over to InfluxQL, I’m guessing the query would be different?
Thanks

If you are indeed changing from SQL to InfluxQL, yes, the query will be different. More explanations and examples can be found here.