# Query data influx

**URL:** <https://community.influxdata.com/t/query-data-influx/18542>\
**Category:** InfluxDB 2\
**Tags:** influxdb, flux\
**Created:** [February 24, 2021, 9:43am UTC](https://community.influxdata.com/t/query-data-influx/18542 "2021-02-24T09:43:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anis](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@Anis](https://community.influxdata.com/u/Anis)\
**Post date:** [February 24, 2021, 9:43am UTC](https://community.influxdata.com/t/query-data-influx/18542/1 "2021-02-24T09:43:43Z")

</div>

Hello,

Please for querying data with flux into Influxdb2.0, can I query from a predefined variable ?  
option = “275” and sometimes option =“269”. It depends the user choice.

> ```
> query = 'from(bucket: "POC")|> range(start: -30d)|> filter(fn: (r) => r._measurement == option)'
> 
> ```

I also tried these two syntax but they don’t work.

```
 query = 'from(bucket: "POC")|> range(start: -30d)|> filter(fn: (r) => r._measurement == ${option})

```

> query = ‘from(bucket: “POC\_Nomenclatures”)|\> range(start: -30d)|\> filter(fn: (r) =\> r.\_measurement =~ /option/)’

Thanks for your support.

---

<div class="post-metadata">

**Author:** ![FixTestRepeat](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fixtestrepeat/32/5208_2.png) [@FixTestRepeat](https://community.influxdata.com/u/FixTestRepeat)\
**Post date:** [February 27, 2021, 12:48am UTC](https://community.influxdata.com/t/query-data-influx/18542/2 "2021-02-27T00:48:25Z")

</div>

I think so, though I’ve not used it myself. Eg, if you made a variable for user to specify the bucket, you’d reference that in flux as

```auto
v.bucket

```

You would likely want to use the map variable type, so that you can use a more meaningful name than 269 or 273 for the users to select.

Take a look at these pages

> **[Use and manage dashboard variables | InfluxDB OSS 2.6 Documentation](https://docs.influxdata.com/influxdb/v2.0/visualize-data/variables/)**
>
> Dashboard variables allow you to alter specific components of cells’ queries without having to edit the queries, making it easy to interact with your dashboard cells and explore your data.

> **[Create a dashboard variable | InfluxDB OSS 2.6 Documentation](https://docs.influxdata.com/influxdb/v2.0/visualize-data/variables/create-variable/)**
>
> Create dashboard variables in the Data Explorer, from the Organization page, or import a variable.

> **[Dashboard variable types | InfluxDB OSS 2.6 Documentation](https://docs.influxdata.com/influxdb/v2.0/visualize-data/variables/variable-types/)**
>
> Overview of the types of dashboard variables available in InfluxDB

---

<div class="post-metadata">

**Author:** ![Anis](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@Anis](https://community.influxdata.com/u/Anis)\
**Post date:** [March 1, 2021, 11:24am UTC](https://community.influxdata.com/t/query-data-influx/18542/3 "2021-03-01T11:24:59Z")

</div>

Hello,

Thank you for your reply but the query that I want to do comes from a user choice. It doesn’t exist into another bucket.

Thanks.

---

<div class="post-metadata">

**Author:** ![Franky1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/franky1/32/6666_2.png) [@Franky1](https://community.influxdata.com/u/Franky1)\
**Post date:** [March 1, 2021, 11:45am UTC](https://community.influxdata.com/t/query-data-influx/18542/4 "2021-03-01T11:45:42Z")

</div>

Go to InfluxDB 2.0 UI  
Settings \> Variables \> Create Variables  
Enter a name (be careful, some names are keyword and not allowed), select Type CSV, enter the values (see example below).  
Afterwards it should be possible to access this variable in flux with `v._option` (in my example) and also in the dashboard as dropdown selection.

 ![variable](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/e/eaff76c1aabeeda0a06dab740545bf51e86a3055.jpeg)

---

<div class="post-metadata">

**Author:** ![Anis](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@Anis](https://community.influxdata.com/u/Anis)\
**Post date:** [March 1, 2021, 11:48am UTC](https://community.influxdata.com/t/query-data-influx/18542/5 "2021-03-01T11:48:47Z")

</div>

> [@Franky1](#):
>
> the dashboard as dropdown selection

Thank you so much. It wasn’t clear in the documentation.
