Can I use a Template Variable in the Metric Script Field

How do I define and use a ‘custom’ variable. I tried creating a Template Variable like so…

image

…but if I use the value in a Script Calculation like so…

image

…it doesn’t work. The Query Inspector shows that the literal variable text (i.e. $TotalThroughput) is inserted in the query, rather than the value I assigned to the variable (i.e. 18174).