Use selected legend item as variable in query


I have a panel that has a left and right scale (Gbps on the left and number of subscribers on the right). If you’re familiar with mobility a bit, each node in the mobility network can host multiple APNs. My panel display all the APNs for that node in the legend.

Normally, Grafana shows Gbps for all the APNs that are in the legend as separate lines, which is expected. If the user clicks on one of the legend entries (ie only one APN), Grafana displays Gbps for that APN only. But what if I want to use that APN selection as a variable in the query that is used on the subscribers side of the graph. So say the user selects APN X from the legend, I want to use X in the separate query to show only the number of subscribers for that APN.

In a nutshell, is there some kind of tag or variable that references the selected legend item, that can be used in a separate query on the same panel.

Thank you,

Solved my own problem by modifying the schema.