Add variables to Grafana using influxDB V2 flux language

i’m not a Grafana expert , i want to add variables to my dashboard so here’s my querry :

from(bucket: "test4")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "FourFrittage")
  |> filter(fn: (r) => r["_field"] == "variable_value")
  |> filter(fn: (r) => r["variable_name"] == "${variable_name}") 
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
  |> yield(name: "last")

this queery does’nt give the expected result. I’m expecting to have variable where i can choose whcih variable to display in my time series plugin:

image

Hi @lorry96

Does this example help?

Did you define your variables like this?

Note how my variable syntax below differs from yours:

from(bucket: "EIAtest7")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "ElectricPowerOperations")
  |> filter(fn: (r) => r["_field"] == "value")
  |> filter(fn: (r) => r["type"] =~ /^${type:regex}$/ )
  |> filter(fn: (r) => r["region"] =~ /^${region:regex}$/ )
  |> group(columns: ["region", "_measurement"], mode:"by") 
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "HourlyData")