well, I have table
at Grafana I create Grafana’s variable $countryOfUser which have list of countries by name of countries and code of countries.
In order to get a list of mapped values, I use a query with 2 entities:
SELECT name AS __text, code AS __value FROM billingCountry
you can see at screenshoot
And then dashboard users can use the filter on a graph or table where they see the names of countries.
And in sql query, I use country codes, since they are indexed for me
and I use code for got only from needed countries using by index of countries
UNIX_TIMESTAMP(MAKEDATE(YEAR(registered), DAYOFYEAR(registered))) as time_sec,
COUNT(User.id) as value,
CONCAT("New Registrations ", IF ( $countryOfUser ='ALL', '', $countryOfUser)) as metric
LEFT JOIN Country On Country.code = User.countryCode
WHERE $__timeFilter(User.registered) AND IF('ALL' in ($countryOfUser), TRUE, (Country.code in ($countryOfUser)))
GROUP BY DATE_FORMAT(registered,"%Y-%m-%d")
As a result, I got a quick query, since I use indexed fields
is it enough? Or you need some more details?