Grafana/Influxdb: How to get difference fist() - last() in singlestat panel

Hi, I like to have a Singlestat Grafana panel which shows the diiference between the first() and last() value of a query. I am able to get those values in table:

resulting in:

but I want the difference between these two values so I can use it in a Singlestat panel. Is there a method to do this in Grafana/InfluxDB?


Use Toggle Edit Mode, from the Menu at the end (≡), and enter the string directly. For my SingleStat, my Solar values are M.I. so I have something like:

SELECT max("value") - min("value")  FROM "house-energy-total" 
WHERE "topic" = 'house/energy_total/solar'  AND $timeFilter

Worked! Thank you very much!

1 Like