Calculate value from previous row value, which is calculated as well

  • What Grafana version and what operating system are you using?
    8.2.0

  • What are you trying to achieve?
    i have an influxdb storing my energy data: total consumption, total pv-delivery and total pv-generation. from these values i can extract how much of the generated power have been consumed by myself (total-pv-generation - total-pv-delivery). this is done via transformation in grafana. now i want this to be shown on a pe rmonth basis. this doesn’t work because i need to calculate the self-consumption on the previous row-calculation.
    any idea?

  • How are you trying to achieve it?
    i have no clue…

let me give example data:

date | pv-delivery | pv-generation | to be calculated: self-consumption
2022-01 | 100 | 200 | → 100
2022-02 | 200 | 350 | → 50 (150 generated, 100 have been delivered)
2022-03 | 450 | 800 | → 200 (450 generated, 250 delivered)
[…]

my self-consumption would be caluculated by: pv-generation - pv-delivery for initial value.
any ideas how to put this directly into a flux-query?