I am trying to visualize power comsumption and power delivery for my house/solar plant in Grafana.
Data is stored in a influxdb.
What I store in the influxdb are the meter readings for consumption and delivery.
So I thought I would get the sum of power consumption and delivery per day with a select difference in grafana.

SELECT difference(mean("value")) / 1000 FROM "PV_sum_consumed" WHERE $timeFilter GROUP BY time(1d) fill(null)
SELECT difference(mean("value")) / 1000 FROM "PV_sum_produced" WHERE $timeFilter GROUP BY time(1d) fill(null)

This will give me the following: (sorry for German screenprints)
power consumption = Netzbezug
power delivery = Einspeisung

But when I calculate the max value “manually” I will get other sums.

SELECT max("value") / 1000 FROM "PV_sum_consumed" WHERE $timeFilter GROUP BY time(1d) fill(null)
SELECT max("value") / 1000 FROM "PV_sum_produced" WHERE $timeFilter GROUP BY time(1d) fill(null)

I am not super familiar with InfluxQL, but perhaps it’s because you are calculating the difference of the mean values, and not the difference of the max values? What happens if you change your query to this?

SELECT difference(max("value")) / 1000 FROM "PV_sum_consumed" WHERE $timeFilter GROUP BY time(1d) fill(null)
SELECT difference(max("value")) / 1000 FROM "PV_sum_produced" WHERE $timeFilter GROUP BY time(1d) fill(null)

I need to get back to this because I have found an issue.
As you can see in my picture I am doing this chart for the last 7 days.
I realized that the last day (today-7) has wrong values.
Regardless if I use “spread” or “difference”/“max” or any other calculation. So this means it´s a problem with the timeframe.

My query is as followed:
SELECT spread(“value”) / 1000 FROM “PV_sum_consumed” WHERE $timeFilter GROUP BY time(1d)
Relative Time ist set to 7d
Even if I set it it to 7d/d (which I have learned stands for using full days) I see the same error but with this I get 1 additional day.

Hi @togi
Can you explain what exactly is wrong with the results you are seeing? Is it that the calculated value for each of the 7 days is wrong, or that Day 1 is wrong (truncated?), or that Day 7 is wrong? Or something else?

OK, so the earliest day in the 7-day series is incorrect because (I suspect) it’s a rolling 7-day period, but not 7 whole days. In other words, the earliest day in the 7-day series is getting truncated.

I do not now if InfluxQL has a way to deal with this. In Flux, I have used this: