This query works, but the IF/ELSE looks strange. Is there a more simple way, like a COALESCE function? I want to treat a field as ZERO if it’s NULL.
from(bucket: "PV")
|> range(start: 2022-12-31T00:00:00+01:00, stop: 2022-12-31T23:59:59+01:00)
|> map(fn: (r) => ({ r with autarky: 100.0 * (1.0 - (r.grid_power_plus / (r.house_power + (if r.wallbox_charge_power > 0 then r.wallbox_charge_power else 0.0)))) }))
|> keep(columns: ["_time", "autarky"])