That’s even better. You can use SQL to create key/value pairs. See doc: Microsoft SQL Server template variables | Grafana documentation
Another option is a query that can create a key/value variable. The query should return two columns that are named
__text
and__value
. The__text
column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allow you to have a friendly name as text and an id as the value.
Example (sorry, no MSSQL syntax, standard PostgreSQL):
Use your MSSQL knowledge and code required business logic in the SQL (e.g. CASE, comparison, subqueries, …) based on input datasource variable.