from(bucket: “quote”)
|> range(start: -10m)
|> filter(fn: (r) => r._measurement == “domestic” and r._field == “volume”)
|> group(columns: [“stockCd”])
|> aggregateWindow(every: 1m, fn: sum)
|> fill(value: 0.0)
|> set(key: “_measurement”, value: “1m”)
|> group(columns: [“stockCd”])
|> map(
fn: (r) =>
({r with
_value: r._value / previous value // previous record value
}),
)
Hello guys, I want to obtain the result of calculating the current value as shown above and the value of the previous record. What query should I use to fetch the value of the previous record?
Hello @rlagudcks132
You can use timeshift() to shift all your data and then join it together with the original data.
However Flux can be quite slow. You might be better off using a client library and doing this type of work with python for example.
Anaisdg:
You can use timeshift() to shift all your data and then join it together with the original data.
However Flux can be quite slow. You might be better off using a client library and doing this type of work with python for example.
Is it more efficient to perform somewhat complex data cleaning tasks at the application level rather than the query level?