Map function: Values from previous rows

Hi Team, @Anaisdg , @scott , @grant1

Is there any way we can use map() or something similar that can use values from previous rows please? :pray:

I’m trying to create a column call pct_change where in
pct_change = value from colA at time t / value from colB at time t-1


Hey @alespour , maybe you have an idea based on your answer in this [post] ?(Create column based on previous row value - #4 by alespour)

This has been a long-requested feature of Flux. There is an issue tracking a scan function that would solve this problem: EPIC: scan function · Issue #4671 · influxdata/flux · GitHub

There is a way to do it now, but it’s really hacky and requires that your data is in regular intervals. Essentially you query the data twice, time-shift the 2nd set by the data’s interval, and then join the two sets together. It can be a very brittle operation.