Complex Query , try to bounce (max : 100 ) a value


With grafana & influxdb, i’m calculating a estimate of the cost of my heating house.
I’m calculating the percent of utilization via this kind of request :
SELECT ($Consigne - “Température” )/ $Ecart * 100 FROM “XXXX”

i want to limit the result value of this single stat to 100 (aka 100%)

I known i can use Set range mappings in single state but i also use this precent in a more complex query : cost of my heating :
SELECT ( $Consigne - “Température” )/ $Ecart * 2.5KWatt/Hour * 0.1272€/KWatt/Hour * $NbPoints / 8.57 (i have a point every 7mm exactly 8.57 == 60/7 ) FROM “XXXX”
On this, ( $Consigne - “Température” )/ $Ecart should never be > 100, Otherwise my calcul is wrong. Any idea how to make this ?

Thanks in advance

Yes, I’m interested in this general area of development too. I have some aircraft heights and decibel readings. I want to simply go mean(10000 - height), for example, in the dashboard query, so that ‘lower’ and ‘louder’ shows in a simpler way on the graph.