I’m basically trying to achieve what’s explained in this answer:
with the only difference that I would like to rescale a collection of series labelled by tags, not just one single series. I tried throwing a group() in the pipeline but obviously it’s not that easy.
I also wonder if there’s a simple trick to rescale, maybe a multiplicative version of: data |> difference() |> cumulativeSum() used to shift the whole series by its first value. This would be something like: data |> 'ratio()' |> 'cumulativeProd()'.
I ended up implementing the multiplicative version of “diff |> cumsum”. I’ll put it here in case anyone is interested. Essentially, it’s a good substitute for the method by @scott that I quoted in my question.
import "math"
logarithm = (tables=<-) =>
tables
|> map(fn: (r) => ({
r with
_value: math.log(x: r._value)
})
)
exponential = (tables=<-) =>
tables
|> map(fn: (r) => ({
r with
_value: math.exp(x: r._value)
})
)
data
|> group(columns: ["mytag"])
|> aggregateWindow(every: 1d, fn: mean) // to align the series in time
|> logarithm()
|> difference()
|> cumulativeSum()
|> exponential()