If Statement in Template

Hi All, hoping someone can help me out. I have connected my inverter to my home assistant deployment. It returns a value for the Battery Power. Home assistant needs two values for this for the energy dashboard. What i want to do is if it returns a positive number (feeding the house) write it to a sensor and if it returns a negative number (charging) write it to another sensor. So far i have my IF statement in place to check if the number is positve or negative but on the value it returns is there a way to return a value of another sensor instead of the value i type in? YAML below.

        unit_of_measurement: "Wh"
        state: >
         {% set charge = states('sensor.battery_power') | float %}
         {% if charge > 0 %} 0
         {% else %} charge
         {% endif %}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

Ultimately i would like to take the “else” value and return the originally referenced ‘sensor.battery_power’ value, and convert it from the negative number it will show a positive version.

Thanks

        unit_of_measurement: "Wh"
        state: >
         {% set charge = states('sensor.battery_power') | float %}
         {% if charge > 0 %} 
           0
         {% else %} 
           {{ charge | abs }}
         {% endif %}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

And for the other sensor:

        unit_of_measurement: "Wh"
        state: >
         {% set charge = states('sensor.battery_power') | float %}
         {% if charge < 0 %} 
           0
         {% else %} 
           {{ charge }}
         {% endif %}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

you my sir @tom_l are a legend!