How to change logic

I need to display the water level. The ultrasonic sensor sends the value in cm. Each time the level drops, the value increases as the distance increases. How to do this?

How about “subtract the value from a fixed constant”, where the constant is
based on the depth of the tank? Let the water get to its lowest level, see
what the value read from the sensor is, and set the constant to that.

Antony.

what datasource are you using?

Datasource is mysql.

Assuming that the sensor produces a measurement in centimeters, and that the distance of the sensor to the bottom of the tank is about 4m,
You could use something like this:

SELECT
(400 - measurement) as level,
time
FROM yourtable
WHERE $__timeFilter(time)