hello everyone,
can anyone help fix this flux script used to project by two or more years using window function without aggregation?
from(bucket:“bucket-name”)
|> range(start:2002-03-04T03:00:01.000000000Z, stop:2003-03-04T07:00:00.000000000Z)
|> filter(fn: (r) => (r[“_measurement”] == “measurement-name” and r[“id”] == “64138fa4-ebd1-43da-a477-1969790daada”))
|> filter(fn: (r) => (r[“_field”] != “string_field”))
|> map(fn: (r) => ({ r with Year: date.year(t: r._time) }))
|> group(columns:[“Year”, “_field”])
|> window(every:2y)
|> toFloat()
|> set(key:“aggregation”, value:“None”)
|> map(fn: (r) => ({ r with None: r._value }))
|> drop(columns:[“tag1”, “tag2”])
|> map(fn: (r) => ({ r with alias: r.Year }))
|> pivot(rowKey:[“alias”, “Year”], columnKey:[“aggregation”, “_field”], valueColumn:“_value”)
I only need to retrieve the starting of each window period. when running it, I get the same result of one year no matter of the period used in the window function.
the script is dynamically generated based on user input, if the user specify any aggregation then aggregateWindow is used.
Thanks!