# Using the Value of a Template Variable to Select Another Value

**URL:** <https://community.grafana.com/t/using-the-value-of-a-template-variable-to-select-another-value/54457>\
**Category:** Grafana\
**Tags:** templating\
**Created:** [October 8, 2021, 6:14pm UTC](https://community.grafana.com/t/using-the-value-of-a-template-variable-to-select-another-value/54457 "2021-10-08T18:14:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kshull](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kshull](https://community.grafana.com/u/kshull)\
**Post date:** [October 8, 2021, 6:14pm UTC](https://community.grafana.com/t/using-the-value-of-a-template-variable-to-select-another-value/54457/1 "2021-10-08T18:14:39Z")

</div>

- What Grafana version and what operating system are you using? 8.1.2

- **What** are you trying to achieve?  
I have a template constant that indicates which environment is being used. I will have dashboards set up in 3 different environments so the value of the environment variable will change can have the following values:

dev, int, prod

The Apis I am monitoring will have different domain names based on the environment selected.  
For example, in Dev the domain name would contain “.m2d”, in Int is would be “.m2i”, and prod would be “.m2p”.

So when the value of the environment value is Dev, I would like to have another variable the will pick the right domain name subset.

If environment = “dev” then return “m2d”  
if environment = “int” then return “mdi”

- **How** are you trying to achieve it?  
I’ve attempted to work with template variables to achieve this. The “Custom” variable seems like the best match because it apparently lets you map values and return a different value. But I can’t get it work because the value I am using is a variable.

This is idea of the mapping I’m looking for:  
($Environment.value==“dev”:“m2d”,$Environment.value==“int”:"m2i…)

- What happened?  
I cannot get it to work.

- What did you **expect** to happen?  
I expect to be able to pass in a variable to another template variable and have it return a value based on the value of the variable passed in.

- Can you copy/paste the configuration(s) that you are having problems with?  
This isn’t a configuration issue.

- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us **exactly** what they were.

- Did you follow any online instructions? If so, what is the URL?  
[Templates and variables | Grafana Labs](https://grafana.com/docs/grafana/latest/variables/)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [October 8, 2022, 6:15pm UTC](https://community.grafana.com/t/using-the-value-of-a-template-variable-to-select-another-value/54457/2 "2022-10-08T18:15:04Z")

</div>

Closed on October 8, 2022, 6:15pm UTC

This topic was automatically closed after 365 days. New replies are no longer allowed.
