Auto select data in variable based on what user selects in 1st

  • What Grafana version and what operating system are you using?
    Azure Managed Grafana (Standard) version 10.4.3

  • What are you trying to achieve?
    The dashboard I am trying to create pulls data from multiple data sources. It will have country list as a filter. Unfortunately, data sources I am using, some of them use full country name (example “United States”) vs others just have 2-letter country code (Example “US”). I just want to use country name as single drop down and let queries using 2-letter codes pick up from these selected countries. I thought of using another data source with name-code mapping and use it with Join but my data sources have limited support to Join operators it wont work. I need a dedicated variable for each filter, ideally, I want country name as to dropdown and 2-letter codes automatically picked up in a separate variable. Users must be able to select multiple countries from the drop down so that is another criteria.

  • How are you trying to achieve it?
    I tried using Infinity Collection & CollectionLookup options but that works for only single entry.

Within Infinity, I’ve added additional data source (CSV) and manually added all the country names & country codes (comma separated). Idea was to use chained variable like implementation but it is not working as I wanted.

Infinity data source with Comma separated country name & codes

On the dashboard, I created 2 variables"

  1. This references the datasource that i’ve added.

  1. On the 2nd variable, I manually listed same countries but with Code, Name and used filter option.

  • What happened?
    The outcome is unreliable. Sometimes the codes are picked up correctly, sometimes they didn’t.

  • What did you expect to happen?
    I want 2 variables on the dashboard

  1. “Country names”
  2. “Country codes”; this I want automatically generated based on what user selected in country names.

Data for both name & codes will be supplied by me through CSV.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Provided above.

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

  • Did you follow any online instructions? If so, what is the URL?
    Grafana documentations on variables, chained variables and Infinity data sources.

in the final data that will be filtered which of the two data filters will be used?

country code or country name?
using business variable

on this data

Both of them will be used. Some data sources I have use CountryNames and others use CountryCode. I want a unified view from multiple sources on single dashboard. I have not tried Business Variable, is that something worth using?

that helped. Thanks

1 Like