Hello,
im currently trying to migrate to flux thanks to the query builder someone so familiar with flux can manage and i got everything working except 2 queries that use math to change the value displayed.
This is the query in question.
I just want to calculate the value *-1
from(bucket: "telegraf")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["topic"] == "openWB/pv/1/W")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
My old query would be this
SELECT last("value") *-1 FROM "mqtt_consumer" WHERE ("topic" = 'openWB/pv/W') AND $timeFilter GROUP BY time($__interval) fill(null)
i just could use math ( *-1) oder math ( *1000) but i have a hard time to figure out how to do this in flux.
From what i read i have to use map but i don’t know exactly how.
i have tried adding
|> map(fn: (r) => r._value * -1))
but that fails