i have an influxdb storing my energy data: total consumption (power from grid), total pv-delivery (power send to grid) and total pv-generation. from these values i want to calculate my own consumed pv-power.
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?
@astrakid Assuming pv-delivery and pv-generattion are stored as fields, you’d query both fields, pivot() them into columns, then use map() to operate on the different column values in each row. Something like this:
hi,
thx for your suggestion. the data is stored as type. but if i understand correctly, than data is only calculated on monthly values, which works for 30d, but not for data >1 month, because the data is stored as absolute values, not relative.