Wrong energy consumption calculation


I am new to the community and to Home Assistant as I am only starting with it. I am working on the Energy Dashboard with my consumption and return to the grid. I am using two physical sensors, one which measures what my house is consuming on electricity and one which is measuring what my solar panels are producing. The sum of both is the result what I am either consuming from the grid or what I am returning.

The energy dashboard only lets me add the value of both sensors to either consumption or return energy. This leads to the result shown in the attached Screenshot. It completely seperates both values as if I would never use the solar enegry myself, before I return it to the grid.

I think I need custom, calculated values for the consumption and return values in the energy dasboard, based on the measured values from my physical sensors. Unfortunately I do not know how to create these values and add them to the dashboard. Maybe someone has the same issue?