Can't get chart displaying data when selecting more than one value in dropdown in flux query

Hi, the below query works fine until I select more than one item from the variable q_line

from(bucket: "volt_sense")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
  |> filter(fn: (r) => r["location"] == "rd2")
  |> filter(fn: (r) => r["_field"] == "${q_line}")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

when I inspect the query I get the following output

from(bucket: "volt_sense")
  |> range(start: 2023-07-12T01:26:52.391Z, stop: 2023-07-12T01:56:52.391Z)
  |> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
  |> filter(fn: (r) => r["location"] == "rd2")
  |> filter(fn: (r) => r["_field"] == "{A0,A1}")
  |> aggregateWindow(every: 1s, fn: mean, createEmpty: false)
  |> yield(name: "mean")


however, I think the line should look like this

|> filter(fn: (r) => r["_field"] == "A0" or r["_field"] == "A1" or r["_field"] == "A2

Hi,

You can use the query as below for selection of more than one value in variable

|> filter(fn: (r) => r[“_field”] =~ /${q_line:regex}/)

Hello @AVVS_Sudheer Thanks for sharing!

Thank you very much for your interest in my query.
I tried the suggested solution

|> filter(fn: (r) => r[“_field”] =~ /${q_line:regex}/)

When I look at the query inspector produces this query

|> filter(fn: (r) => r[“_field”] =~ /(A0|A1|A2|A3)/)

However, I get a

Status: 500. Message: invalid: compilation failed: error @9:22-9:37: invalid expression @9:33-9:36: ” error @9:27-9:33: invalid expression @9:24-9:27: “

somehow I need to produce a string similar to this

|> filter(fn: (r) => r[“_field”] == “A0” or r[“_field”] == “A1” or r[“_field”] == "A2

That works, but how can I create this using a dropdown?

Hi,

You can use this in variable to select multiple values.

r[“_field”] == “A0” or r[“_field”] == “A1” or r[“_field”] == "A2

If you use the above, it will be only 3 values. But it is not good logic. If you have more than 10 fields of the same type like A0,A1 till A10 then the above logic will not work