For creating template variables inside Grafana one can create variables, which are templated with a set of available values.
In InfluxQL one would use
SHOW TAG VALUES FROM "<measurement>" WITH KEY IN ("<prefered_tag>")
For Flux I found
from(bucket: "<bucket-name>")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn:(r) => r._measurement == "<measurement>")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> group()
|> distinct(column: "<prefered_tag>")
to have the same effect.