[Resolved] Use multi value variable in other variable definition (postgres)

Hi all,

I can’t find a way to define variable based on other variable, if other variable is in multi value mode.
I use postgres datasource.
I was using influxdb before, and it worked as expected

Example :

1st variable : select account_id from accounts
–> OK. Variable defined in multi value mode

2nd variable :
SELECT distinct country_id from countries where account_id IN ($account_id)
–> Templating. Template variables could not be initialized: Cannot read property ‘meta’ of undefined

If I set account_id variable in single value mode, it works as expected and I can get my countries variable as expected

Syntax is correct beacause I can use in ($account_id) in graphes/tables/singlestat in my dashboard, with multi value enabled.

Problem only occurs when trying to define variable .


SELECT distinct country_id from countries 
WHERE account_id IN (${account_id:raw})

Maybe you will need another advance formatting and/or column type casting in your SQL query as well.

1 Like

Tried with some advanced formatting, but it does not work.

For me syntax is ok, because “where account_id in (‘1’,‘2’,‘10’,‘15’)” is what postgres expects.

And if I use this syntax in graphe query, it works as intended.

fixed in 5.3.2 with https://github.com/grafana/grafana/issues/13600