I want to add two data series and I have the following code for it. Unfortunately I get the following error. I assume it is because of the syntax in line 7.
|> map(fn: (r) => ({ r with Total: (r.“Total home consumption Battery” + r.“Total home consumption PV”) }))
Does anyone know where the problem is?
from(bucket: "telegraf")
|> range(start: month)
|> filter(fn: (r) => r["_measurement"] == "modbus")
|> filter(fn: (r) => r["_field"] == "Total home consumption Battery" or r["_field"] == "Total home consumption PV")
|> aggregateWindow(every: 1mo, fn: spread, createEmpty: false)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({ r with Total: (r."Total home consumption Battery" + r."Total home consumption PV") }))
|> yield(name: "spread")