How to prevent displaying the total sum of A + B if columns A + B are empty

Solution 1:

You can extend the formula to check whether the value in the column to the left is empty or not:

=if(j3>0;sum(h$2:h3);"")