I had the same issue when several queries were specified in a custom variable, looks like it’s not possible to use variables there.
Could you confirm that if you use query from Metric variable instead of ${Metric} in this panel everything works as expected (i.e. $id is replaced by ‘QTR’ or other selected value)?
dont use inline metric queries but rather use stored pricedures and pass the variables to the stored proc
As is that 2nd variable is unreadable and unmaintainable.
maybe use a mock table query
select 'QTR' as __text,
'call quarterly()' as __value
from mysql doc
Stored procedures offer a significant performance advantage over ad-hoc SQL queries .