Flux equivalent to SQL IN clause for integers?

Hello. I have a a variable in grafana with multiple values where these values are mapped to integers.

I can use multiple values in my flux expression with regex based filters with grafana expansion ${variable:pipe} when field type data is “string”.

from(bucket: "oracle/autogen")
  |> range(start: -2h)
  |> filter(fn: (r) => r["_measurement"] == "tablespace" and r["environment"] =~ /^${environment:pipe}$/ and r["arq"] =~ /^${arq:pipe}$/ )

But I can not use it when field type is integer

from(bucket: "oracle/autogen")
  |> range(start: -2h)
  |> filter(fn: (r) => r["_measurement"] == "tablespace" and r["environment"] =~ /^${environment:pipe}$/ and r["arq"] =~ /^${arq:pipe}$/ )
  |> filter(fn: (r) => r["db"] =~ /^${db:pipe}$/ )
  |> v1.fieldsAsCols()
  |> filter(fn: (r) => r["status"] =~ /${status:pipe}/ ) 

It shows this error.
image

Is there any way to build a filter like sql in clause in flux with integers ?
something like the following

  |> filter(fn: (r) => r["status"] in (/${status:csv}/ ) 

how can I build this filter when I don’t know how much options user will choose ?

Hello @toni-moreno,
you can use the string() function to convert the value to a string in the filter.

Let me know if that helps!

It is working ok. Thank you @Anaisdg !!

1 Like