How to reuse sensor data without obtaining data again from the sensor?

Hi, This is my first day of using ESPHome to code my nodemcu, connected with a SR04.

I am using it to find water level of my 2meter deep tank. After reading documentation and forums I was able to configure it and it show perfect calculations.

Now I want to also show the water present in the tank in “Liters”.

sensor:
  - platform: ultrasonic
    trigger_pin: D0
    echo_pin: D1
    unit_of_measurement: "%"
    icon: "mdi:water-percent"
    timeout: 4m
    accuracy_decimals: 0
    update_interval: 60s
    name: "Overhead Water Tank"

    filters:
      - lambda: return (1-((2-x)/2))*100;
      - filter_out: nan

I have two options either to reuse the above code and change the lambda formula for liter calculation.

Or I read somewhere that I can use “platform: template” or something like that to use the data from previous code and process it in a different way and feed it to the home assistant.

I am unable to find any forum post or documentation on this. Can somebody guide me with this?

Thanks
Akash