Select values from more than 2 rows

Hi,

I want to select values from more than 2 rows. I can select only from two rows
like r[“state”]=“KA” or r[“state”]= “AP”

Is there any function like in to select more than 2 rows like in (“AP”,“KA”,“MH”) in influx

Shouldn’t this work?

r["state"]="KA" or r["state"]= "AP" or r["state"]= "MH"

Hi,

It is working fine for me. I want another method like in (“AP”,“KA”,“MH”)

I’m sorry, but I do not understand your question. Maybe you can try re-phrasing what you have tried and what does not work.

Hi,

I have a flux query as below

from(bucket: “bucket1”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Measurement1”)
|> filter(fn:(r) => r[“state”] ==“AP” or r[“state”] ==“KA”)
|> filter(fn:(r) => r[“sales”] ==2000)
|> filter(fn: (r) => r[“tag”] == “Clothes” )

the above query is working fine for me. My doubt is can we write the above query in another way as below

from(bucket: “bucket1”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Measurement1”)
|> filter(fn:(r) => r[“state”] in (“AP”,“KA”)
|> filter(fn:(r) => r[“sales”] ==2000)
|> filter(fn: (r) => r[“tag”] == “Clothes” )

Is this is possible in influx

I believe you can query several fields using a regex. Can you try this?

  |> filter(fn: (r) => r["_field"] =~ /^(AP|KA)$/)

or perhaps

  |> filter(fn: (r) => r["_field"] =~ /^("AP"|"KA")$/)

Hi,

Thanks a lot. I tried this query, it is working fine

Which expression worked?

Hi,

I tried |> filter(fn: (r) => r[“_field”] =~ /^(AP|KA)$/)