# All/Multi-Value with key-value variables

**URL:** <https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754>\
**Category:** Dashboards\
**Tags:** templating\
**Created:** [July 14, 2022, 9:27am UTC](https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754 "2022-07-14T09:27:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bityob](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bityob](https://community.grafana.com/u/bityob)\
**Post date:** [July 14, 2022, 9:27am UTC](https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754/1 "2022-07-14T09:27:53Z")

</div>

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

- **What** are you trying to achieve?

I have two variables that depends on each other.  
v1 → x1  
v2 → x2  
v3 → x3

Instead of having two variables, I want to have only one, and to have two variables defined when I choose the first variable.

So I when choose `v1` from the droplist, I’ll have two variables; v=v1 and x=x1 etc.

So I defined a custom variable with such value -

```auto
v1 : x1,v2 : x2,v3 : x3

```

And I’m using {v:text} or {v:value} to get the key/value in the queries.

The problem is with All/Multi-Value that doesn’t work.

All I get in such cases is the values but can’t get the keys concanted the same way.

```auto
(x1|x2|x3)

```

But I want also the have an option to get the keys too…

```auto
(v1|v2|v3)

```

Instead each place with `${v:text}` is converted to `All` etc.

---

<div class="post-metadata">

**Author:** ![f20180212g](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@f20180212g](https://community.grafana.com/u/f20180212g)\
**Post date:** [December 5, 2022, 7:14am UTC](https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754/2 "2022-12-05T07:14:32Z")

</div>

Hi @bityob, By any chance, did u figure out a way to achieve this?

---

<div class="post-metadata">

**Author:** ![pedrogomes](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@pedrogomes](https://community.grafana.com/u/pedrogomes)\
**Post date:** [July 12, 2023, 12:03pm UTC](https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754/3 "2023-07-12T12:03:09Z")

</div>

same, for a query like:  
sort\_desc(sum(metric{label=~“${options:text}”}) by (version) )

Grafana is sending this to prometheus:  
sort\_desc(sum(metric{label=~“option1 + option2 + option3”}) by (version) )

instead of

sort\_desc(sum(metric{label=~“option1|option2|option3”}) by (version) )

---

<div class="post-metadata">

**Author:** ![denismoc](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@denismoc](https://community.grafana.com/u/denismoc)\
**Post date:** [July 18, 2023, 10:55pm UTC](https://community.grafana.com/t/all-multi-value-with-key-value-variables/68754/5 "2023-07-18T22:55:06Z")

</div>

I found the solution to this!!!

> **[Variable syntax | Grafana documentation](https://grafana.com/docs/grafana/latest/dashboards/variables/variable-syntax/#pipe)**
>
> Variable syntax Panel titles and metric queries can refer to variables using two different syntaxes:
> $varname This syntax is easy to read, but it does not allow you to use a variable in the middle of a word. Example:...

So there are more than just :text and :value that you can append after the variable name.  
What we are looking for here is the Pipe operator to be used when concatinating the results.

so you would access your values by entering: ${options:pipe}
