How to sum over multiple measurements

Hello,

i am new to the flux language and i am trying to create the yearly solar energy yield of a set of 5 solar inverters. For each the inverter the produced energy is calculated from its power over time using the integral function. So far this works, but finally i want to sum all of them together.

from(bucket: "mybucket")
  |> range(start: 2016-07-31T08:12:27Z, stop: 2020-07-31T08:12:27Z)
  |> filter(fn: (r) => r["_measurement"] =~ /^WR \d.total-dc-power$/)
  |> filter(fn: (r) => r["_field"] == "value")
  |> drop(columns: ["month", "year", "device", "identifier"])
  |> window(every: 1y)
  |> integral(unit: 1h)

The data returned looks like:

How can i finally sum all values together?

sum() seems to be applied only once for each row but not for all rows together.

I think you just need to add group()

Edit: sorry the math isn’t my forte, fairly sure what ever operations you want to do on the combined set requires that it’s collapsed into a single group. Hopefully this gets you closer to the solution

  |> group()
  |> sum()

did the trick. Thanks a lot!

2 Likes