Chained variables in grafana from using SQL

Hi there

I simply can’t get this to work and can’t figure out why. My variables in Grafana are fetched via a SQL database query. There are 4 columns in my table and each is created as a variable in grafana.

Let’s take column1 and column2 as examples - column1 has a one-to-many relationship with column2. I’d like to have chained variables so that when I choose a value from column1 it filters the variable values of column2. This is my query for column2 variable but it doesn’t work:

select column2 from @table where column1 = '$column1var'
;

surely that should work? But it just returns nothing

Use browser inspector and check how that variable is expanded. It can be "value" and I guess you expect value (use advance formatting to fix that, e. g. :raw so Grafana won’t be doing any magic value formatting)

1 Like

I tried using this:

where column1 IN (${column1var:csv})

and also

where column1 IN (${colcumn1var:raw})

both without any luck - they don’t return anything.

When I swap out the variable for the actual value, it does work - so feels like it should be about the way Grafana is inputting those values

what data type is column1