I figured out a messy way to do it.
First create a separate query for each data series:
from(bucket: "energy")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == "s-31" and
r.topic == "tele/growlight-s31/SENSOR" and
r._field == "totalwh"
)
This by itself yields a single data series, like this:
Then create a reduction expression for each data series query to grab only the last value:
Then finally create a math expression and add all the reduction expression values together:
I say this is messy because for n number of data series being summed, you need 2n+1 queries/expressions, so the query page gets real cluttered. There’s also the drawback that, while it does return the sum of the latest value in each data series:
it returns exactly one value, so the usual trendline in the stat visualization is missing.
If anyone knows a better way to do this, please let me know, but I’m marking this as the solution for now.