InfluxDB 2.x error expected IDENT, got STRING

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")

Hello @Cavekeeper,
if you use quotes you need brackets otherwise with dot notation you don’t quotes

  |> map(fn: (r) => ({ r with Total: (r["Total home consumption Battery"] + r["Total home consumption PV"]) }))

Lmk if that does the trick :slight_smile:

1 Like

Hello @Anaisdg , yes this is the trick. Many thanks for your help.