Now, how can I pass the value when clicked to another panel’s where clause?
Like if I click on any “State” in the above panel, e.g., “Alabama” - I need to pass that value to another panel’s where condition - is it possible?
I have seen the data link, which creates a url - thats not what I am looking for…I need the clicked value to be captured and passed as a variable to another panels query…
Why not using link to itself and setting a variable along the way, then applying the variable on that “detail” panel? True, refresh will be triggered, but putting that aside, effect will be as you wanted it.
On your table panel, go to the column style options for a particular field and select Render As Link. This will open a set of Link options. Now go to the address bar of your browser, copy the whole link and paste it into Url field of the Link Options:
Now delete everything to the right of ? and replace it with ?orgID=1&var_country=$__cell&from=$__from&to=$__to.
Save and reload. If you now click on the link, you’ll come to the same place, but if you look at the address bar, you’ll have var_country set to the chosen country, which means that $country variable is now set to your chosen country.
Now go to the second panel and edit your query to something like metric{country_label=~"$country"}.
Let me know if this works for you.
Being a newbie - struggling a little bit to find out - where I can find the Col. Style option, may take some time - but I will…here is my screen shot on the table setup
I see column width etc., but not the screen you posted - again, I will do my homework and findout.
Now, here is what I am trying to achieve…
I have two panels - one which ‘As of Date’ by State and the right one is by county.
What I need is - on the left panel, when I select a ‘State’ like Alabama, I need to pass that clicked value as State to the right panel to bring all the Deaths in those Counties in that State.
I am pretty sure - the info you provided may solve this problem, but I need to first figure out - where I see the column style option and choose the Render value as link option.
This is the whole ‘States’ panel edit screen - couldn’t find the Column Style option & Render value as link also…Am I doing something wrong here? Thank you - N
You’re using newer version of Grafana, but no worries. You should be able to find those fields on the right side if you click Overrides.
Could you also show me the query of the right panel. I was assuming Prometheus as data source, but looks like you have something else. No worries, you’ll just have to stick your country variable to some specific place.
Hi @nageshyr, I am back, so let’s push this through to the end. You sorted out Data Link brilliantly and it seem only the right side query is problematic. First, remove the trailing $after $state_nm. Then, I am not sure that you need regex expression in there, but I may be wrong. But you’ll probably need to add ' in front and at the back of the variable, like this '/^$state_nm/'. Or perhaps double quote, ", don’t know. I am not familiar with InfluxDB, but just try to tweak the query without the variable until it spits out what you want. What I am also seeing in the query is a leading space in front of Alabama, like /^ Alabama$/, which may also be causing difficulties.
Let me know how it goes and we’ll go from there.
I tried the option you mentioned and also looked into some InfluxDB forums, as per InfluxDB docs - the regex is simply
/$state_nm/ so I tried /$Alaska/ - /Alaska/ - and the others as you mentioned - ‘/^Alaska/’ - “/^Alaska/” - ‘/$Alaska/’ - “/$Alaska/”
Good. I think the query is good, but the value of $state_nm isn’t as it’s prefixed with a space (looking at query from query inspector on one of the screenshots above). I think we need to look at the left panel query and see how those state values get populated and why is there a space prefix.
Query looks good. I suspect the problem in the ingested data. I recall that there’s a trim() function you can apply to the field. Do it for field us_state. This should get rid of that space.