# Limit users to access Variable values

**URL:** <https://community.grafana.com/t/limit-users-to-access-variable-values/8513>\
**Category:** Elasticsearch\
**Tags:** templating\
**Created:** [July 3, 2018, 10:00am UTC](https://community.grafana.com/t/limit-users-to-access-variable-values/8513 "2018-07-03T10:00:59Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 31, 2022, 2:18am UTC](https://community.grafana.com/t/limit-users-to-access-variable-values/8513/13 "2022-07-31T02:18:08Z")

</div>

It looks like that variable does exist

> **[Add and manage variables | Grafana documentation](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/)**
>
> Add and manage variables The following table lists the types of variables shipped with Grafana.
> Variable type Description Query Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. Add a query...

based on the above here is an example with sample ddl & dml

```auto
use grafana 
--this is my own ms sql server database 
--for testing things out not grafana's db

go

drop table companies

create table companies(companyid int identity(1,1), 
companyname varchar(50) )

insert into companies
select 'Acme' union
select 'Zimza'

drop table users;
create table users(username varchar(50))

insert into users
select 'ddenson'

drop table usercompanies
create table usercompanies(username varchar(50), 
companyid int)

insert into usercompanies
select u.username, c.companyid
from companies c , users u
where c.companyname = 'Acme'

```

here is how the companies variable is setup

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/3/a/3abf8c2e2edd1554645845c9f612642dbe0e7cce.png)

here is an ms sql profiler showing that it does work when I am logged in ddenson

![image](https://us1.discourse-cdn.com/grafana/original/3X/c/1/c1da9f429e7736dce6e9eae788fc0034fb881104.png)

and the resulting Companies drop down (not sure why the 1 is there) but you get the drift.  
as you can see ddenson only sees the company he is associated with = Acme.

![image](https://us1.discourse-cdn.com/grafana/original/3X/1/2/12d1b75c7f6f4ed64bd2164e8e197ff1a2a6dd88.png)

just implement this principle to your environment and whatever backend you use

---

_[View the full topic](https://community.grafana.com/t/limit-users-to-access-variable-values/8513)._
