Heatmap if case

Hi,
I am using InfluxDB as time series database as a resource and trying to write query for Heatmap dashboard in Grafana.


First line in heatmap is like a heartbeat which means I have data and the system is up.
The query for the first line is in the following:

Other lines in heatmap for several data that shows anomaly scores which varies between 0 and 100. Its query is in the following:

What I want to do here is putting these two queries in if case. In other words, if the system is up I want to run the first query and see the only first line of heatmap.Otherwise, I want the second query to run and see the other lines of heatmap (excluding heatmap line).

Do you have any idea? Any help is appreciated. Thank you very much.