You can wrap that in an array formula like so:
=SUM(IF(G2:Z2 - G1:Z1 > 0, G2:Z2 - G1:Z1, 0))
Then to enter it as an array formula, hold SHIFT
and CTRL
while pressing ENTER
.
If you did it right, it will be surrounded with curly brackets when you select the cell:
{=SUM(IF(G2:Z2 - G1:Z1 > 0, G2:Z2 - G1:Z1, 0))}
Note that you should not type the curly brackets.
As a side note, I would normally recommend using the MAX
function to test for 0 in cases like this. It simplifies the formula from this:
=IF(G2:Z2 - G1:Z1 > 0, G2:Z2 - G1:Z1, 0)
To this:
=MAX(G2:Z2 - G1:Z1, 0)
However, this simply will not work in an array formula because the MAX
function aggregates the array similar to SUM
, meaning that in this case, it first finds the max of G2:Z2 - G1:Z1
and then finds the max between that max and zero, which is definitely not what we were attempting to do.
I have discovered a working function!! Now, is there any way to reduce this mess so I can easily go from G-Z and beyond?
=SUM(If((G4-G3)>0,G4-G3,0),if((H4-H3)>0,H4-H3,0),if((I4-I3)>0,I4-I3,0)) – Tami Veldura – 2015-12-10T22:41:25.407