Good morning,
I have this simple query, I want to understand how to divide the data here with a factor.
Ex: value / 10 = …
from(bucket: "VH_Messwerte")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
|> filter(fn: (r) => r["topic"] == "Energie/VH/Spannung/L1" or r["topic"] == "Energie/VH/Spannung/L2" or r["topic"] == "Energie/VH/Spannung/L3")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
Thanks for your help
Matthias
Anaisdg
2
Hello @matze1708,
You can use the map function.
from(bucket: "VH_Messwerte")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
|> filter(fn: (r) => r["topic"] == "Energie/VH/Spannung/L1" or r["topic"] == "Energie/VH/Spannung/L2" or r["topic"] == "Energie/VH/Spannung/L3")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> map(fn: (r) => ({ _value: r._value /10 }))
is it also possible to Calculate one value /100 and another value / 10, in the same query?
Thank you
Hello @matze1708,
Yes you can do:
|> map(fn: (r) => ({ _value_by_100: r._value /100, _value_by_10: r._value/10 }))