Referencing "_time" from previous query as "range(start: , stop:now())" for a following query. I can't get it to work

Brilliant suggestion @gazpachoking! You are correct in that one must get an individual record. @mauflege: There are probably several ways to do this, but in my sample dataset I got it to work using the Extract Scalar Value feature.

Something like this should work:

import "sql"
data=from(bucket: "TEMP_DATA")
  |> range(start: -2m)
  |> filter(fn: (r) => r["_measurement"] == "placeholder_1")
  |> group()
  |> last()
  |> keep(columns: ["_time"]) // not sure this line is needed
  |> limit(n:1)
  |> yield(name: "table1")

tempInfo = data
    |> findRecord(
        fn: (key) => key._measurement == "placeholder_1",
        idx: 0,

batchinsert=from(bucket: "Bucket2")
    |> range(start: tempInfo._time, stop: now())
    |> filter(fn: (r) => r["_measurement"] == "placeholder_1")
    |> yield(name: "table2")
1 Like