# Exclude item from variable query

**URL:** <https://community.grafana.com/t/exclude-item-from-variable-query/13883>\
**Category:** Grafana\
**Created:** [January 27, 2019, 10:47am UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883 "2019-01-27T10:47:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rossoreed](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/rossoreed/32/37601_2.png) [@rossoreed](https://community.grafana.com/u/rossoreed)\
**Post date:** [January 27, 2019, 10:47am UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/1 "2019-01-27T10:47:43Z")

</div>

I have created a template which enables me to select a particular device to populate the chart, which works fine except the dropdown includes an item that I don’t want to show.  
The tag “diverter” is on a different measurement, and it’s data is not compatible with the chart.

![var2](https://us1.discourse-cdn.com/grafana/original/2X/f/f48954bd2d9f8f22a9a2bb68b2fb7a6446cb6162.png)

The variable for “Type” is shown below, and I have tried excluding “device” by using Regex, but that doesn’t seem to work.

Can the Query be modified to only include the measurement “sensors”, and exclude “iot”?

![var1](https://us1.discourse-cdn.com/grafana/original/2X/7/7104deff75afd4c84777e920ae5e8e41e9fab1d6.png)

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [January 27, 2019, 10:51am UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/2 "2019-01-27T10:51:28Z")

</div>

> **[Schema Exploration | InfluxDB OSS 1.3 Documentation](https://docs.influxdata.com/influxdb/v1.7/query_language/schema_exploration/#show-tag-values)**
>
> InfluxQL is an SQL-like query language for interacting with data in InfluxDB. The following sections cover useful query syntax for exploring your schema.
> SHOW DATABASES SHOW RETENTION POLICIES SHOW SERIES SHOW MEASUREMENTS SHOW TAG KEYS SHOW TAG...

You can use `FROM <measurement>`

---

<div class="post-metadata">

**Author:** ![rossoreed](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/rossoreed/32/37601_2.png) [@rossoreed](https://community.grafana.com/u/rossoreed)\
**Post date:** [January 27, 2019, 10:58am UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/3 "2019-01-27T10:58:06Z")

</div>

That’s what I tried first, but grafana will not accept FROM in that query.

If I add `FROM "sensors"` to the existing query, it just errors.

---

<div class="post-metadata">

**Author:** ![rossoreed](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/rossoreed/32/37601_2.png) [@rossoreed](https://community.grafana.com/u/rossoreed)\
**Post date:** [January 27, 2019, 11:03am UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/4 "2019-01-27T11:03:54Z")

</div>

![test](https://us1.discourse-cdn.com/grafana/original/2X/6/667bb519532c0164f1b75b0a287ad8c143360e9c.png)

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [January 27, 2019, 4:53pm UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/5 "2019-01-27T16:53:11Z")

</div>

You have incorrect syntax. Correct one:

`SHOW TAG VALUES FROM "<measurement>" WITH KEY = "<key>"`

---

<div class="post-metadata">

**Author:** ![rossoreed](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/rossoreed/32/37601_2.png) [@rossoreed](https://community.grafana.com/u/rossoreed)\
**Post date:** [January 27, 2019, 6:20pm UTC](https://community.grafana.com/t/exclude-item-from-variable-query/13883/6 "2019-01-27T18:20:17Z")

</div>

Yes, that works OK, Jan  
Thank you, I appreciate your help.

Paul
