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)?