A
Anthony
I have a SUM array formula that has multiple nested IF statements,
making it very inefficient. My formula spans over 500 rows, but here
is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array
is greater than zero, and if they are, it sums those in the second
part of the formula.
You will notice that the same IF statement is repeated in there twice,
which to me is inefficient, but is the only way I could get the
correct answer.
The example data I have is as follows:
Row Col A
1 120
2 120
3 120
4 120
5 120
6
7 100
8 100
9 100
10 100
11 100
12
13 50
14 50
15 50
16 50
17 50
The answer should be 350 in this instance using the formula I
mentioned above.
If I tried to put in a MAX statement within the array, therefore
removing the test to find where it was greater than zero, so it was
like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in
each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or
make it more efficient by not needing to repeat an IF statement in
there?
making it very inefficient. My formula spans over 500 rows, but here
is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array
is greater than zero, and if they are, it sums those in the second
part of the formula.
You will notice that the same IF statement is repeated in there twice,
which to me is inefficient, but is the only way I could get the
correct answer.
The example data I have is as follows:
Row Col A
1 120
2 120
3 120
4 120
5 120
6
7 100
8 100
9 100
10 100
11 100
12
13 50
14 50
15 50
16 50
17 50
The answer should be 350 in this instance using the formula I
mentioned above.
If I tried to put in a MAX statement within the array, therefore
removing the test to find where it was greater than zero, so it was
like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in
each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or
make it more efficient by not needing to repeat an IF statement in
there?