InfluxDB: SumTotal over last value of the day over all days (Total)

Hello everyone,

I’ve been trying to solve the following problem for days, but I just can’t get it to work.

I am using the following:
Grafana v10.2.3

I have an electricity meter that counts the imported electricity, but only for the day in question. The next day it starts again at 0.
The values are stored in the InfluxDB as shown in the following picture:

Now I would like to add up the last value of a day with all other days so that I get a total for all days. It is important that I only use the last value of each day.

What I have already tried:
SELECT max(“value”) FROM “3EM_TodaySumImport” WHERE $timeFilter GROUP BY time(1d)

It therefore at least shows the last value in the table.

But now I would like to add them up so that I get a total and not for each day separately.

Then I tried to get all of Max’s data together on Group365:
SELECT max(“value”) FROM “3EM_TodaySumImport” WHERE $timeFilter GROUP BY time(365d)

The result is even worse:

I expected that if I group max over all days, I would get a value over all 365 days.

Can you please help me to create a bar gauge that counts the complete current import?

Thanks for the help!

Best regards

You could use a Grafana transformation to sum the Max values from each day.

Or you can rewrite your query. Maybe something like this?

SELECT SUM(max_value) FROM (
SELECT MAX(“value”) AS max_value FROM “your_measurement”
GROUP BY time(1d)