# Select values from more than 2 rows

**URL:** <https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305>\
**Category:** Systems\
**Created:** [August 28, 2023, 9:07am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305 "2023-08-28T09:07:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AVVS\_Sudheer](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/avvs_sudheer/32/13075_2.png) [@AVVS\_Sudheer](https://community.influxdata.com/u/AVVS_Sudheer)\
**Post date:** [August 28, 2023, 9:07am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/1 "2023-08-28T09:07:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [August 28, 2023, 12:12pm UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/2 "2023-08-28T12:12:16Z")

</div>

Shouldn’t this work?

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

---

<div class="post-metadata">

**Author:** ![AVVS\_Sudheer](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/avvs_sudheer/32/13075_2.png) [@AVVS\_Sudheer](https://community.influxdata.com/u/AVVS_Sudheer)\
**Post date:** [August 29, 2023, 3:42am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/3 "2023-08-29T03:42:21Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [August 29, 2023, 9:32am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/4 "2023-08-29T09:32:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AVVS\_Sudheer](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/avvs_sudheer/32/13075_2.png) [@AVVS\_Sudheer](https://community.influxdata.com/u/AVVS_Sudheer)\
**Post date:** [August 29, 2023, 9:49am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/5 "2023-08-29T09:49:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [August 29, 2023, 10:13am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/6 "2023-08-29T10:13:51Z")

</div>

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

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

```

or perhaps

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

```

---

<div class="post-metadata">

**Author:** ![AVVS\_Sudheer](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/avvs_sudheer/32/13075_2.png) [@AVVS\_Sudheer](https://community.influxdata.com/u/AVVS_Sudheer)\
**Post date:** [August 29, 2023, 10:27am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/7 "2023-08-29T10:27:50Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [August 29, 2023, 11:03am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/8 "2023-08-29T11:03:48Z")

</div>

Which expression worked?

---

<div class="post-metadata">

**Author:** ![AVVS\_Sudheer](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/avvs_sudheer/32/13075_2.png) [@AVVS\_Sudheer](https://community.influxdata.com/u/AVVS_Sudheer)\
**Post date:** [August 29, 2023, 11:04am UTC](https://community.influxdata.com/t/select-values-from-more-than-2-rows/31305/9 "2023-08-29T11:04:42Z")

</div>

Hi,

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