I want to implement multi selection in Grafana with influx query

I have dropdown where I’m doing the multi selection, after multi selection my influx query is updated but I’m not able to get the value after multi selection.

Hi @anjali07

That is indeed tricky and I did not figure it out until recently. One has to format like this in the Flux query:

|> filter(fn: (r) => r["region"] =~ /^${region:regex}$/ )

or if using InfluxQL, like this:

...WHERE ("type"::tag = 'Demand' AND "region"::tag =~ /^$region$/) AND ...

Screenshots:

query for above:

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"] == "Demand")
  |> filter(fn: (r) => r["region"] =~ /^${region:regex}$/ )
  |> group(columns: ["region", "_measurement"], mode:"by") 
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "HourlyData")

and in InfluxQL:

SELECT sum("value") FROM "ElectricPowerOperations" WHERE ("type"::tag = 'Demand' AND "region"::tag =~ /^$region$/) AND $timeFilter GROUP BY region, time($__interval) fill(previous)

Hi, Thank you for your response,
in my case multi selected value should come in measurement, so I want Multi selected value in _measurement. Is there any way for implementation.

Sure. Did you already create a variable for measurement, and if yes, can you please share it here?

Also, are you using Flux or InfluxQL?