# How do I calculate the sum of 2 columns, using the max from each row?

I have data in two columns. I would like the sum of the two columns, using the maximum value for each row.

For instance

``````C1  C2
1   2
4   3
11
10
5   7
``````

The result would be 2+4+11+10+7.

I would prefer if the solution worked in Google Spreadsheets, but if that can't happen Excel would be ok.

-

For a one cell solution you can use an "array formula" like this in excel

`=SUM(IF(A2:A6>B2:B6,A2:A6,B2:B6))`

confirmed with CTRL+SHIFT+ENTER

In google docs you should be able to do the same - either use CTRL+SHIFT+ENTER with the above or use

`=ARRAYFORMULA(SUM(IF(A2:A6>B2:B6,A2:A6,B2:B6)))`

-
Works perfectly. Thanks. – Chris Marasti-Georg Jan 1 '12 at 17:39

Is this too simple?

``````C1  |C2   |C3
1   |2    |=MAX(A2,B2)
4   |3    |=MAX(A3,B3)
11  |     |=MAX(A4,B4)
|10   |=MAX(A5,B5)
5   |7    |=MAX(A6,B6)
|     |=SUM(C2:C6)
``````
-
Looks good. If no one posts a one-cell answer I'll accept. – Chris Marasti-Georg Jan 1 '12 at 17:22