Home » excel » debugging – Array formula not working in Excel

debugging – Array formula not working in Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have the following table in Excel (blank spaces are empty):

    A  B  C  D
1   1
2   3
3   4
4  -2
5   4
6   9
7   8
8
9
10

I would like to return the minimum of column A from A1 to A1000000, using the QUARTILE function, while excluding all negative values. The reason I want it from A1 to A1000000 and not A1 to A7 is because I want to update the table (adding new rows starting from A8) and have the formula also automatically update. The reason I want the QUARTILE and not MIN function is because I will be extending it to calculate other statistics like 1st and 3rd quartile.

This function works correctly and returns 1 (pressing ctrl+shift+enter):

QUARTILE(IF(A1:A7 > -1, A1:A7), 0)

However, when I tried the following, it returned 0 when it should still return 1 (pressing ctrl+shift+enter):

QUARTILE(IF(A1:A1000000 > -1, A1:A1000000), 0)

I also tried the following and it returned 0 (pressing ctrl+shift+enter):

QUARTILE(IF(AND(NOT(ISBLANK(A1:A1000000)), A1:A1000000 > -1), A1:A1000000), 0)

Anybody have a solution to my problem?

How to&Answers:

Create a dynamic named range, called for example, rng, defined by =OFFSET($A$1,0,0,COUNT($A1:$A10000),1)

Then modify your array formula to refer to rng, via =QUARTILE(IF(rng >-1,rng), 0)

Answer:

Actually what you have works. Try doing:

=QUARTILE(IF(A:A > 0,A:A ),0)

The reason you are returning 0 is that a blank cell is considered to be of the value 0 when this formula is ran. For example, erase one of the values in the A1:A7 range and your original formula will return 0. Also, I would run the formula on the entire A column if possible (for readability, etc.)

Or do you need to return a “0” if that number is in the list?