Totalling separate colums

Copper Contributor

Hey all, I am trying to total the number in two columns only when there are numbers in both columns. I've tried messing around with the SUMIFS function but not getting far.

Here's an example

Column 1       Column 2

4                     9

                       8

1                     2

7                       

If I add the numbers when only both columns have data I get 4+9+1+2=16

And it ignores the 8 and 7 since they don't have values in the adjacent column.

Is there a way to do this?

Thanks

1 Reply

@jacobg98 'Let's say your data are in A2:B5.

 

=SUMPRODUCT(A2:B5*(A2:A5<>"")*(B2:B5<>""))

or

=SUM(FILTER(A2:B5,(A2:A5<>"")*(B2:B5<>"")))