Hello,
i have pricing-records of fuel stations that i would like to shift into another bucket with min/max/mean transformations.
The records look like this and are stored in a bucket with 40d-retention.
_value,_field,_measurement,location,type
1.899,station1,Tankstelle,locationx,type1
1.959,station2,Tankstelle,locationy,type2
2.019,station3,Tankstelle,locationz,type3
Now i would like to have a task that runs every 24h and creates min/max/mean records grouped by location and type. Which stations (_field) doesn’t matter.
option task = {name: "Tankstelle_24h", every: 24h}
data =
from(bucket: "40days")
|> range(start: -task.every)
|> filter(fn: (r) => r["_measurement"] == "Tankstelle")
|> group(columns: ["location", "type"])
price_min =
data
|> min()
|> set(key: "_field", value: "price_min")
price_max =
data
|> max()
|> set(key: "_field", value: "price_max")
price_mean =
data
|> mean()
|> set(key: "_field", value: "price_mean")
union(tables: [price_min, price_max, price_mean])
|> set(key: "_measurement", value: "Tankstelle_24h")
|> to(org: "myorg", bucket: "ages")
The problem is that min() and max() are generated in the ages-bucket but not mean().
If i test the same query with the data explorer (without the |> to option) the raw-view shows “NaN” in _time column but it shows mean-records.
What is wrong in my query or what did understood wrong?
Thanks