# Grafana MSSQL variable problem

**URL:** <https://community.grafana.com/t/grafana-mssql-variable-problem/25599>\
**Category:** Grafana\
**Tags:** templating\
**Created:** [February 5, 2020, 11:50am UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599 "2020-02-05T11:50:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luke0815151](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@luke0815151](https://community.grafana.com/u/luke0815151)\
**Post date:** [February 5, 2020, 11:50am UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/1 "2020-02-05T11:50:10Z")

</div>

Hello,  
I want to have a dashboard with templating. The datasource of the dashboad is MSSQL, also known as TQL and the relevant line in the query is this one:

AND GroupName = ‘FullStack’

So the group name is actually a string in the database.

I know want to define a variable $team, so that the user of the dashboard can choose metrics for a specific team by choosing in the dropdown.

My problem is that I did not managed it to use that variable. I’ve tried things like  
AND GroupName = $team /\* Error here: No such column FullStack\*/  
AND GroupName = ‘’’$team’’’ /\* Empty result where it should not be empty \*/

So how can I solve this problem?

---

<div class="post-metadata">

**Author:** ![borisberthet](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@borisberthet](https://community.grafana.com/u/borisberthet)\
**Post date:** [February 5, 2020, 12:39pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/2 "2020-02-05T12:39:59Z")

</div>

Hello,

Try the query as :

WHERE GroupName IN ($team)

---

<div class="post-metadata">

**Author:** ![luke0815151](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@luke0815151](https://community.grafana.com/u/luke0815151)\
**Post date:** [February 5, 2020, 12:44pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/3 "2020-02-05T12:44:08Z")

</div>

Hi, I’ve tried WHERE GroupName IN ($team) and received this error:  
“sql: expected 1 arguments, got 0”

before the query was  
WHERE GroupName = ‘somevalue’ and it did work, so it seems that this is not an error in the query itself.

---

<div class="post-metadata">

**Author:** ![borisberthet](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@borisberthet](https://community.grafana.com/u/borisberthet)\
**Post date:** [February 5, 2020, 1:06pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/4 "2020-02-05T13:06:49Z")

</div>

How is your variable defined ?  
“GroupName” does have multiple values ?  
Do you want to be able to filter on multiple GroupNames ?

---

<div class="post-metadata">

**Author:** ![luke0815151](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@luke0815151](https://community.grafana.com/u/luke0815151)\
**Post date:** [February 5, 2020, 1:09pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/5 "2020-02-05T13:09:02Z")

</div>

The variable has the type “Query” which returns values like:  
FullStack  
Backend  
Frontend

Currently the multiple values mode is not active, however it could be useful.

---

<div class="post-metadata">

**Author:** ![borisberthet](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@borisberthet](https://community.grafana.com/u/borisberthet)\
**Post date:** [February 5, 2020, 1:20pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/6 "2020-02-05T13:20:22Z")

</div>

Then define your variable as “Multi-value” and use the provided query above.  
You should be able to select it also via the dropdown on your panel and see it filtering your graphs.

---

<div class="post-metadata">

**Author:** ![luke0815151](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@luke0815151](https://community.grafana.com/u/luke0815151)\
**Post date:** [February 5, 2020, 1:55pm UTC](https://community.grafana.com/t/grafana-mssql-variable-problem/25599/7 "2020-02-05T13:55:53Z")

</div>

> [@borisberthet](#):
>
> GroupName IN ($team)

That worked now, thank you very much.
