Simple math on Flux query

Trying to make the jump from InfluxQL to Flux, and need a little help.

In InfluxQL, we put the two orange lines on the graph in Grafana using math(1.025) and math(0.975) as separate queries:


SELECT mean("HTFN8FRSP") *.975 FROM "stations" WHERE $timeFilter GROUP BY time(1m) fill(null)

In Flux, here is a mock-up query. I have tried adding or multiplying values to the Setpoint (e.g. + 3), but no success. Am sure it’s something simple that I am missing.

from(bucket: "bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["tag1"] == "sensor1")
  |> filter(fn: (r) => r["_field"] == "actualValue" or r["_field"] == "setpointValue")
  |> filter(fn: (r) => r["_measurement"] == "measurement")
  |> aggregateWindow(every: 5s, fn: last, createEmpty: false)
  |> yield(name: "last")

I got the same general graph to appear now in Grafana using multiple Flux queries. This seems to defeat the purpose of Flux, which I understand offered more efficient ways to write queries, but this works for now.

you can use the Transform tab do do math


Thank you, and using a simple binary operation is something that I overlooked. It works fine to create the 2 lines (UCL and LCL), but it seems that by using a Transformation, I cannot do an Alert. In other words, Grafana allows either transformations or alerts, but not both. Is this true?

I don’t know about alert. Never use it. I do mine through node-red. Sorry