Array Formula Calculates Empty Cells as Zero - incorrect result!

jswhip

Board Regular
Joined
Jan 19, 2005
Messages
69
I am using the percentile function within an array. If I use it in conjunction with with an "IF" statement, I get the wrong result. For example, this formula returns the correct calculation (it's using a much smaller data set than actual).

{=PERCENTILE(L2:L8,0.02)}

However, if I embed this with an "IF" statement/array, I get the wrong result of 14,135:

{=PERCENTILE(IF(A2:A8="FGLMC 3",L2:L8,""),0.02)}

The values in column "L" (used in the Percentile function) are:
<null>
117,793
213,284
188,539
188,763
163,244
162,770

The 2% percentile should be 122,291. If I use the "Evaluate Formula" option from the "Formula" tab, I can see converted the null value to zero.

How do I get Excel to NOT convert the null to zero?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Quick correction - the data values s/b:
<null>
117,793
213,284
188,539
188,763
163,244
162,770
 
Upvote 0
Correction II -

For whatever reason using null within brackets isn't showing. The data values are:
_null_
117,793
213,284
188,539
188,763
163,244
162,770
 
Upvote 0
In VBA, when you want to specify a "blank" by using "", you actually have to place your quotes in quotes, like this: """"

So, this is what it should look like in your code: {=PERCENTILE(IF(A2:A8="FGLMC 3",L2:L8,""""),0.02)}
 
Upvote 0
Your formula seems to work for me:


Excel 2010
ABCDEFGHIJKLMN
2FGLMC 3 122290.7122290.7
3FGLMC 3FGLMC 3117,793122290.7122290.7
4FGLMC 3FGLMC 3FGLMC 3213,284162807.9162807.9
5FGLMC 3FGLMC 3FGLMC 3FGLMC 3188,539162798.4162798.4
6FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3188,763162789162789
7FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3163,244162779.5162779.5
8FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3FGLMC 3162,770162770162770
Sheet8
Cell Formulas
RangeFormula
L2=""
M2=PERCENTILE(L2:L$8,0.02)
M3=PERCENTILE(L3:L$8,0.02)
M4=PERCENTILE(L4:L$8,0.02)
M5=PERCENTILE(L5:L$8,0.02)
M6=PERCENTILE(L6:L$8,0.02)
M7=PERCENTILE(L7:L$8,0.02)
M8=PERCENTILE(L8:L$8,0.02)
N2{=PERCENTILE(IF(A2:A8="FGLMC 3",L2:L8,""),0.02)}
N3{=PERCENTILE(IF(B2:B8="FGLMC 3",L2:L8,""),0.02)}
N4{=PERCENTILE(IF(C2:C8="FGLMC 3",L2:L8,""),0.02)}
N5{=PERCENTILE(IF(D2:D8="FGLMC 3",L2:L8,""),0.02)}
N6{=PERCENTILE(IF(E2:E8="FGLMC 3",L2:L8,""),0.02)}
N7{=PERCENTILE(IF(F2:F8="FGLMC 3",L2:L8,""),0.02)}
N8{=PERCENTILE(IF(G2:G8="FGLMC 3",L2:L8,""),0.02)}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Andrew,

Thank you for replying - much appreciated.

Noticed in your example that cell L2 has a formula to return "null". If you were to clear the contents of cell L2, you will see the result I initially described.

For what it's worth, if I enter a space into cell L2, the problem is resolved. It seems using Percentile in conjunction with the array/if formula, Excel evaluates an empty cell as zero. Thoughts on how to resolve?

Thank you.
 
Upvote 0
Kentetsu -

Thanks for following up. In this example, the blanks don't come into play as all the rows match the selection criteria. Also, I believe for statistical calculation purposes, a space connotates a much different meaning than missing - missing values aren't used in the calculation whereas spaces would be used. Thus, the wrong result would be returned (at least for my purpose).
 
Upvote 0
That's the trick!

I had tried multiple iterations of your solution, but couldn't get the correct calculation. This saves me the effort of modifying the data set to insure missing values aren't used in statistical calculations.

Thank you very, very much!
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,946
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top