# Use variable in another variable

**URL:** <https://community.grafana.com/t/use-variable-in-another-variable/63028>\
**Category:** Grafana\
**Tags:** templating, query-help\
**Created:** [March 28, 2022, 8:11am UTC](https://community.grafana.com/t/use-variable-in-another-variable/63028 "2022-03-28T08:11:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![piccadil](https://avatars.discourse-cdn.com/v4/letter/p/b9e5f3/32.png) [@piccadil](https://community.grafana.com/u/piccadil)\
**Post date:** [March 28, 2022, 8:11am UTC](https://community.grafana.com/t/use-variable-in-another-variable/63028/1 "2022-03-28T08:11:34Z")

</div>

- What Grafana version and what operating system are you using?  
Grafana v7.5.3

- **What** are you trying to achieve?  
I have two “custom” variables -  
env - has following values: test,prod  
instanceidtest - _someid_  
instanceidprod - _anotherid_  
I want to template variable in another variable something like this - $instanceid${env}

- Can you copy/paste the configuration(s) that you are having problems with?  
“targets”: [

---

<div class="post-metadata">

**Author:** ![anon70503803](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@anon70503803](https://community.grafana.com/u/anon70503803)\
**Post date:** [March 29, 2022, 9:31pm UTC](https://community.grafana.com/t/use-variable-in-another-variable/63028/2 "2022-03-29T21:31:08Z")

</div>

welcome to the :grafana: forum, @piccadil

It sounds like you want to use chained variables. Here are some useful starting points and example dashboards in our public sandbox 👍

- [example dashboard](https://play.grafana.org/d/000000056/templated-dynamic-dashboard?orgId=1&var-app=country&var-server=All&var-interval=1h)
- [Add and manage variables | Grafana documentation](https://grafana.com/docs/grafana/latest/variables/variable-types/chained-variables/)
- [Variables | Grafana documentation](https://grafana.com/docs/grafana/latest/variables/)
- [Variables | Grafana documentation](https://grafana.com/docs/grafana/latest/variables/variable-examples/)
