Variables in the web interface - time range


I wish to store variables that are automatically adapting to the time window my dashboard is set on. For example:

from(bucket: "BUCKET_NAME")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "hydraulic.oil.pressure")
  |> pivot(valueColumn: "_value", rowKey: ["_time"], columnKey: ["_measurement"])
  |> map(fn: (r) => ({ 
      _time: r._time,
      _value: r["hydraulic.oil.pressure"] > 40

This variable is a filter by value, and I want to rapidly know if I am with a positive non negligible value. But it seems the time range of the variable is not adapting to the time range of the query I use it in:

|> map(fn: (r) => ({
      _time: r._time,
      _value: if v.isOilPressureUp then r["rudder.rake.port.request"] / 1000.0 - r["rudder.port.rake"] / 4096.0 else 0.0,

Is this possible?

unfortunately i’m not able to answer your question as a while back i had the same question and to be honest, i’m still wondering. i need some answers for my breakfast related project. just wanted to ask you to come with updates if you do find an answer.

Hello @yyvus,
That looks possible, although to be honest I’m a little confused by your question. What’s wrong with your flux query/what error are you getting? Can you please provide me with a sample input and expected output?
Thank you!