# Setting variable to Y-label value in DataLinks

**URL:** <https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472>\
**Category:** Dashboards\
**Tags:** data-links\
**Created:** [July 30, 2024, 8:09pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472 "2024-07-30T20:09:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![godd67](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@godd67](https://community.grafana.com/u/godd67)\
**Post date:** [July 30, 2024, 8:09pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472/1 "2024-07-30T20:09:57Z")

</div>

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

- **What** are you trying to achieve?  
Pass a group value to another panel

- **How** are you trying to achieve it?  
Via setting variable and datalinks

- What happened?  
Variable is not set

- What did you **expect** to happen?  
Variable is set, target panel updates data based on the variable value

- Can you copy/paste the configuration(s) that you are having problems with?  
No

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

I have a Bar Chart based on SQL query. It groups data by “product” field and calculates count.

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/5/b/5b3ade5f99c95fdc68d6ad42a5866a2a803f0bed.png)  
I have another panel (table view) - I’d like to click on a bar and show details in that panel for a selected “product”.  
ChatGpt suggested to use Custom variable and a Datalink with a placeholder in a form of var-product=${\_\_field.labels.product} but it does not work, variable is not set. I also tried different placeholders but with the same result. If I use \_\_value.raw, variable is set correctly but to the Count value. Is it possible to achieve what I want? How can I set my variable to a group value- those ones that are painted on an image above 🙂 ?

---

<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 30, 2024, 8:35pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472/2 "2024-07-30T20:35:44Z")

</div>

> [@godd67](#):
>
> click on a bar

welcome to forum

can you point to a bar chart click event in grafana doc?

---

<div class="post-metadata">

**Author:** ![godd67](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@godd67](https://community.grafana.com/u/godd67)\
**Post date:** [July 31, 2024, 5:31pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472/3 "2024-07-31T17:31:41Z")

</div>

> [@yosiasz](#):
>
> bar chart click event in grafana doc

Sorry , not sure what you mean by that?  
Here is a doc how to set data links if you asked about that

> **[Configure data links | Grafana documentation](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-data-links/)**
>
> Configure data links to create links between dashboards and link to external resources

That’s what I see when I click on the bar:  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/3/7/3765c2779e805e5990aa177ac476f5e283cfb056.png)  
What I want to catch and pass to datalink is “Shared services” in this case. Each bar has a diff ManagementZone value.

---

<div class="post-metadata">

**Author:** ![godd67](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@godd67](https://community.grafana.com/u/godd67)\
**Post date:** [July 31, 2024, 7:14pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472/4 "2024-07-31T19:14:53Z")

</div>

Figured!  
Tried all possible placeholders and this one - ${\_\_data.fields[0]} worked!

---

<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, 2024, 9:01pm UTC](https://community.grafana.com/t/setting-variable-to-y-label-value-in-datalinks/127472/5 "2024-07-31T21:01:34Z")

</div>


