Setting variable to Y-label value in DataLinks

  • 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.


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 :slight_smile: ?

welcome to forum

can you point to a 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

That’s what I see when I click on the bar:
image
What I want to catch and pass to datalink is “Shared services” in this case. Each bar has a diff ManagementZone value.

1 Like

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

1 Like