Google Sheets – Take Element-Wise Maximum of Two Columns with Array Formula

google sheets

I want to take element-wise maximum of two columns, that is pick whichever is larger in every row. So, with the input

+-------+
| A  B  |
+-------+
| 3  8  |
| 5  2  |
| 2  7  |
+-------+

the output should be a column with 8, 5, 7.

The function MAX can do this for two values like max(A2, B2) but when I try array formula

=arrayformula(max(A2:A4, B2:B4))

the output is just 8, the overall maximum.

Best Answer

Since it's just two columns,

=ARRAYFORMULA(IF(A2:A4>B2:B4,A2:A4,B2:B4))