Calculating the Difference?

Hello
could you pls hlp me find the problem, thx!

from(bucket: "iobroker_data")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement =~ /modbus.0.holdingRegisters.400[0-9][0-9]_Cell_Voltage_([1-9]|1[0-6])$/
  )
  |> aggregateWindow(every: v.windowPeriod, fn: mean)
  |>group()
  |>drop(columns:["_measurement"])
  |>sort(columns:["_time"])

minimum = data
  |> aggregateWindow(every: v.windowPeriod, fn: min)
  |> map(fn: (r) => ({_time: r._time, minimum: r._value}))

maximum = data
  |> aggregateWindow(every: v.windowPeriod, fn: max)
  |> map(fn: (r) => ({_time: r._time, maximum: r._value}))

differenz = data
  |> aggregateWindow(every: v.windowPeriod, fn: spread)
  |> map(fn: (r) => ({_time: r._time, differenz: r._value}))

union(tables: [minimum, maximum, differenz])

SQL 2.0

Does it produce an error with just this?

union(tables: [minimum, maximum])

Does not change the error message.

I think your question would better answered on the Influx community forum. The only thing I can find re: that error is that it may result of union being called with tables having different schemas.

1 Like