Hi,
Every userId has different records of time.
How could we get the last 7 days records of all userIds ?
In one query, something like ... and start time reference end time
import “influxdata/influxdb/schema”
data = from(bucket: “test”)
|> range(start: -30d)
|> filter(fn: (r) => r[“_measurement”] == “test.Dailies”)
|> filter(fn: (r) => r[“userId”] == “001” or r[“userId”] == “002”)
|> filter(fn: (r) => r[“_field”] == “steps”)
|> last()
|>findRecord(fn: (key) => key._field == “steps”,idx: 0)from(bucket: “test”)
|> range(start: (stop-7d) , stop: data._time)
|> filter(fn: (r) => r[“_measurement”] == “test.Dailies”)
|> filter(fn: (r) => r[“userId”] == data.userId)
|> schema.fieldsAsCols()