Possible to conditionally disable metric query?

I’m using an SQL datasource to query variables for a dashboard and I wondered if there was a way to conditionally disable one metric if no variable was returned for that particular metric query? My whole panel goes down if one variable doesn’t exist and I’m not sure how to fix that.

For example, in my sql code I’m using an IIF() expression and if NULL is returned, then my metric query will be attempting to call a NULL tag which doesn’t work when querying OpenTSDB (I use SQL to call the variables to then pass to opentsdb to query the actual data).

When trying to query with a null variable, I get the error message: “message”: “Missing the metric or tsuids, provide at least one”,