# Dashboard Variables Noob

**URL:** <https://community.influxdata.com/t/dashboard-variables-noob/24828>\
**Category:** Dashboards\
**Created:** [April 28, 2022, 2:38pm UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828 "2022-04-28T14:38:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![subwayfootlong](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/subwayfootlong/32/7263_2.png) [@subwayfootlong](https://community.influxdata.com/u/subwayfootlong)\
**Post date:** [April 28, 2022, 2:38pm UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828/1 "2022-04-28T14:38:18Z")

</div>

Hello all.  
In my bucket, I have 2 measurements, Sensor 1 and Sensor 2. (The sensors are multi-sensors)  
These sensors are the exact same just placed in different areas, so they have the same fields. (temp, light etc…)

What im trying to accomplish is a dashboard with all the fields and then I can just switch the measurement from sensor 1 to sensor 2 and it will switch the measurements accordingly.

How do I accomplish this? I am a noob

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [April 29, 2022, 11:05am UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828/2 "2022-04-29T11:05:18Z")

</div>

Hi @subwayfootlong, not a noob question at all.  
I would create a dashboard variable called `measurments` like so:

```auto
import "influxdata/influxdb/schema"
schema.measurements(bucket: "INSERT_BUCKET_NAME")

```

Then within your dashboard flux. You call your variable like this:

```auto
from(bucket: v.bucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == v.measurments)

```

 ![Screenshot 2022-04-29 at 12.04.12](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/a/ad6d40d62c307b732b0bd68f7ac2f5aeacb02a93.jpeg)

---

<div class="post-metadata">

**Author:** ![subwayfootlong](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/subwayfootlong/32/7263_2.png) [@subwayfootlong](https://community.influxdata.com/u/subwayfootlong)\
**Post date:** [April 29, 2022, 6:15pm UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828/3 "2022-04-29T18:15:10Z")

</div>

Amazing @Jay_Clifford !  
Now Im a step closer to not being a noob.

However, in my case, I wasnt trying to change buckets so my flux Query would be (For anyone strictly following this forum post )

```auto
from(bucket: "INSERT_BUCKET_NAME")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == v.measurments)

```

But you opened my eyes to new possibilities of the dashboard that I can build! Time to get my hands dirty with variables!

---

<div class="post-metadata">

**Author:** ![subwayfootlong](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/subwayfootlong/32/7263_2.png) [@subwayfootlong](https://community.influxdata.com/u/subwayfootlong)\
**Post date:** [April 29, 2022, 6:25pm UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828/4 "2022-04-29T18:25:14Z")

</div>

If I would like to change buckets too, I know I have to create another variable called buckets but what would that variable contain?  
I tried

```auto
schema.measurements(organization: "INSERT_Organization_NAME")

```

But that seems super wrong.

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [May 1, 2022, 10:39am UTC](https://community.influxdata.com/t/dashboard-variables-noob/24828/5 "2022-05-01T10:39:33Z")

</div>

Hi @subwayfootlong,  
Great to see your on your way! To get a dynamic list of buckets you can create the following variable query:

```auto
buckets()
  |> filter(fn: (r) => r.name !~ /^_/)
  |> rename(columns: {name: "_value"})
  |> keep(columns: ["_value"])

```
