Override decimals value dependent?

I have a solar system and display the current generation in Grafana (unit: Energy / Watt (W)).
Is there a possibility to overwrite the decimal places depending on the value?
Example: Value 0-999 with 0 decimal places. If the value is larger (>=1000) then Grafana displays the value in kWh. In this case I would like to have 2 decimal places (1.23 kWh). Is this possible?

Thanks.