Sensor gass consumption help

hello,

I’ll try to monitor my gass costs and maked some sensors.
but when I make this configuration I get an error.

sensor:
  - platform: template
    sensors:
      gasprijs_per_dag:
        friendly_name: "Kosten Gasverbruik Vandaag"
        unit_of_measurement: "EUR"
        icon_template: "mdi:currency-eur"
        value_template: >-
          {% set a = states('sensor.gasverbruik_vandaag') | float %}
          {% set b = states('input_number.gas_prijs') | float %}
          {% set c = states('input_number.gas_leveringskosten') | float %}
          {% set d = states('input_number.gas_vaste_kosten_per_dag') | float  %}
          {% set e = states('input_number.gas_netbeheer_kosten_per_dag') | float  %}
          {% set f = states('input_number.gas_energiebelasting_zone1') | float  %}
          {% set g = states('input_number.gas_opslag_energie_zone1') | float %}
          {{ (((a * b) + a * c) + a * f) + a * g) + d + e | round(2) }}

when I change the last rule to: {{ (((a * b) + a * c) + a * f) + d + e | round(2) }}
then it works but then it is not calculating all parameters because then it miss set g