Is there a Null function?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
This page says that there is a Null function in Excel:

NULL function - Microsoft Support

But if I enter "=null()" in a cell, I get a #NAME? error.

I ask because I want a cell formula to return Null if one of the source cells is missing. The tables below illustrate what I am trying to do. The mini-sheet follows.

Table 1 has 2 data columns with all values present. The two Z columns calculate the Z Scores for the data columns. The Wt ZSum column calculates the weighted sum of the Z Scores.

Table2 shows what happens if some data values are missing. The data means & std devs are correct, but the Z Scores are off.

In Table3, I set the Z Score to zero for any missing data values. Now the Z Score means are correct, but the std devs are off.

In Table 4, I set the Z Score to null (""?) for any missing data values. The Z Score means & std devs are correct, but I get a value error in the sum. I tried returning null(), but that got a #NAME? error as stated above.

In Table 5, I manually set the Z Score to null (delete key) for any missing data values. Now everything is correct. How can I do this in a formula?

1710703036394.png


Cell Formulas
RangeFormula
J3,AE3,X3,Q3J3=AWt
K3,AF3,Y3,R3K3=BWt
E5:E9E5=([@A]-Table1[[#Totals],[A]])/C$11
F5:F9F5=([@B]-Table1[[#Totals],[B]])/D$11
G5:G9,AI5:AI9,AB5:AB9,U5:U9,N5:N9G5=[@[Z A]]*AWt + [@[Z B]]*BWt
L5:L9L5=([@A]-Table2[[#Totals],[A]])/J$11
M5:M9M5=([@B]-Table2[[#Totals],[B]])/K$11
S5:S9S5=IF(ISNUMBER([@A]), ([@A]-Table3[[#Totals],[A]])/Q$11, 0)
T5:T9T5=IF(ISNUMBER([@B]), ([@B]-Table3[[#Totals],[B]])/R$11, 0)
Z5:Z9Z5=IF(ISNUMBER([@A]), ([@A]-Table4[[#Totals],[A]])/X$11, "")
AA5:AA9AA5=IF(ISNUMBER([@B]), ([@B]-Table4[[#Totals],[B]])/Y$11, "")
AG5,AG7:AG9AG5=IF(ISNUMBER([@A]), ([@A]-Table5[[#Totals],[A]])/AE$11, "")
AH5:AH7,AH9AH5=IF(ISNUMBER([@B]), ([@B]-Table5[[#Totals],[B]])/AF$11, "")
C10,AE10,X10,Q10,J10C10=SUBTOTAL(101,[A])
D10,AF10,Y10,R10,K10D10=SUBTOTAL(101,[B])
E10,AG10,Z10,S10,L10E10=SUBTOTAL(101,[Z A])
F10,AH10,AA10,T10,M10F10=SUBTOTAL(101,[Z B])
G10,AI10,AB10,U10,N10G10=SUBTOTAL(101,[Wt ZSum])
C11C11=STDEV.S(Table1[A])
D11D11=STDEV.S(Table1[B])
E11E11=STDEV.S(Table1[Z A])
F11F11=STDEV.S(Table1[Z B])
G11G11=STDEV.S(Table1[Wt ZSum])
J11J11=STDEV.S(Table2[A])
K11K11=STDEV.S(Table2[B])
L11L11=STDEV.S(Table2[Z A])
M11M11=STDEV.S(Table2[Z B])
N11N11=STDEV.S(Table2[Wt ZSum])
Q11Q11=STDEV.S(Table3[A])
R11R11=STDEV.S(Table3[B])
S11S11=STDEV.S(Table3[Z A])
T11T11=STDEV.S(Table3[Z B])
U11U11=STDEV.S(Table3[Wt ZSum])
X11X11=STDEV.S(Table4[A])
Y11Y11=STDEV.S(Table4[B])
Z11Z11=STDEV.S(Table4[Z A])
AA11AA11=STDEV.S(Table4[Z B])
AB11AB11=STDEV.S(Table4[Wt ZSum])
AE11AE11=STDEV.S(Table5[A])
AF11AF11=STDEV.S(Table5[B])
AG11AG11=STDEV.S(Table5[Z A])
AH11AH11=STDEV.S(Table5[Z B])
AI11AI11=STDEV.S(Table5[Wt ZSum])
Named Ranges
NameRefers ToCells
AWt=Sheet5!$C$3AE3, X3, Q3, J3, G5:G9, N5:N9, U5:U9, AB5:AB9, AI5:AI9
BWt=Sheet5!$D$3AF3, Y3, R3, K3, G5:G9, N5:N9, U5:U9, AB5:AB9, AI5:AI9
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
The function NULL is for Sharepoint in a calculated column not Excel

Aha! I didn't pay attention to that.

So, is there any way for the formulas in Column S, which return a zero, or Column Z, which return "", to return a value that will be treated as an empty cell?
 
Upvote 0
Using the Table4 version of returning "", is this an option for the sum column ?
Excel Formula:
=IF([@[Z A]]<>"",[@[Z A]])*AWt + IF([@[Z B]]<>"",[@[Z B]])*BWt
 
Upvote 0
Using the Table4 version of returning "", is this an option for the sum column ?
Excel Formula:
=IF([@[Z A]]<>"",[@[Z A]])*AWt + IF([@[Z B]]<>"",[@[Z B]])*BWt
Yes, that works, but what a pain! I am going to move all of this to a macro where I can use tests that I have a little more confidence in.

I did a little more testing. I'll post screenshots first and then put the mini-sheets at the end.

Test1: I added a Table6 where I defined a named cell (Null) that was empty (AO2). I then returned that in the formula.

VBA Code:
=IF(ISNUMBER([@A]),  ([@A]-Table6[[#Totals],[A]])/AL$11,  Null)

It didn't work. The cells that I need to be empty (AN6 & AO8) still show up as zero.

1710780990358.png


Test2: In one cell (C4) I put ="". Another (D4) was empty. I then copied each to another cell (E4, F4) and ran as many ISxx functions as I could find on all 4 cells. The differences are highlighted.
  1. The yellow cells (C6:D6) show that the empty cell (D4) is blank, but the ="" cell (C4) is not.
  2. The pink cells (C9:D9) show that the ="" cell (C4) contains text, the empty cell (D4) does not.
  3. The orange cells (B5, F5) show that the empty cell (D4) is not a number, but its copy (F4) is.
  4. The green cell (F6) and the second yellow cell (D6) show that while the empty cell (B4) is blank, its copy (F4) is not.
  5. The blue cells (D10, F10) show that the empty cell (D4) is equal to "", but its copy (F4) is not.
Finally, the computational cells (G4:J4) show that an empty cell is treated as a zero in formulas, but a ="" cell is treated as text.

1710781890837.png


I think Excel needs a Null() function.

Here are the mini-sheets:

Weighted Ratings Demo.xlsx
AKALAMANAOAP
2Table6Null
3Weights21
4ABZ AZ BWt ZSum
519-1.32+1.02-1.61
68=0.00+0.44+0.44
737-0.15-0.15-0.44
84+0.44=0.00+0.88
955+1.02-1.32+0.73
10Means3.257.250.000.000.00
11Std Devs1.711.710.870.871.04
Null Test1
Cell Formulas
RangeFormula
AL3AL3=AWt
AM3AM3=BWt
AN5:AN9AN5=IF(ISNUMBER([@A]), ([@A]-Table6[[#Totals],[A]])/AL$11, Null)
AO5:AO9AO5=IF(ISNUMBER([@B]), ([@B]-Table6[[#Totals],[B]])/AM$11, Null)
AP5:AP9AP5=[@[Z A]]*AWt + [@[Z B]]*BWt
AL10AL10=SUBTOTAL(101,[A])
AM10AM10=SUBTOTAL(101,[B])
AN10AN10=SUBTOTAL(101,[Z A])
AO10AO10=SUBTOTAL(101,[Z B])
AP10AP10=SUBTOTAL(101,[Wt ZSum])
AL11AL11=STDEV.S(Table6[A])
AM11AM11=STDEV.S(Table6[B])
AN11AN11=STDEV.S(Table6[Z A])
AO11AO11=STDEV.S(Table6[Z B])
AP11AP11=STDEV.S(Table6[Wt ZSum])
Named Ranges
NameRefers ToCells
'Null Test1'!AWt='Null Test1'!$C$3AL3, AP5:AP9
'Null Test1'!BWt='Null Test1'!$D$3AM3, AP5:AP9
'Null Test1'!Null='Null Test1'!$AO$2AN5:AO9


Weighted Ratings Demo.xlsx
BCDEFGHIJ
3A (="")B (empty)AA (=A)BB (=B)A*5B*5AA*5BB*5
4  0#VALUE!0#VALUE!0
5=ISNUMBERFALSEFALSEFALSETRUE
6=ISBLANKFALSETRUEFALSEFALSE
7=ISNAFALSEFALSEFALSEFALSE
8=ISOMITTEDFALSEFALSEFALSEFALSE
9=ISTEXTTRUEFALSETRUEFALSE
10=""TRUETRUETRUEFALSE
Null Test2
Cell Formulas
RangeFormula
C4C4=""
E4E4=A
F4F4=B
G4G4=A*5
H4H4=B*5
I4I4=AA*5
J4J4=BB*5
C5C5=ISNUMBER(A)
D5D5=ISNUMBER(B)
E5E5=ISNUMBER(AA)
F5F5=ISNUMBER(BB)
C6C6=ISBLANK(A)
D6D6=ISBLANK(B)
E6E6=ISBLANK(AA)
F6F6=ISBLANK(BB)
C7C7=ISNA(A)
D7D7=ISNA(B)
E7E7=ISNA(AA)
F7F7=ISNA(BB)
C8C8=ISOMITTED(A)
D8D8=ISOMITTED(B)
E8E8=ISOMITTED(AA)
F8F8=ISOMITTED(BB)
C9C9=ISTEXT(A)
D9D9=ISTEXT(B)
E9E9=ISTEXT(AA)
F9F9=ISTEXT(BB)
C10C10=A=""
D10D10=B=""
E10E10=AA=""
F10F10=BB=""
Named Ranges
NameRefers ToCells
'Null Test2'!A='Null Test2'!$C$4G4, E4, C5:C10
'Null Test2'!AA='Null Test2'!$E$4I4, E5:E10
'Null Test2'!B='Null Test2'!$D$4H4, F4, D5:D10
'Null Test2'!BB='Null Test2'!$F$4J4, F5:F10
 
Upvote 0
And as you have discovered different functions treat them differently. Some see blank and "" as being the same and some do not eg
=COUNTIFS($D$11:$D$15,"<>" & "") ONLY excludes "empty" cells (generally abbreviated to just "<>")
While SumProduct, Filter etc using the syntax ($D$11:$D$15 <> "") excludes BOTH empty cells and ""
In VBA IsEmpty only picks up empty cells while = "" picks up BOTH empty cells and ""
 
Upvote 0
And as you have discovered different functions treat them differently. Some see blank and "" as being the same and some do not eg
=COUNTIFS($D$11:$D$15,"<>" & "") ONLY excludes "empty" cells (generally abbreviated to just "<>")
While SumProduct, Filter etc using the syntax ($D$11:$D$15 <> "") excludes BOTH empty cells and ""
In VBA IsEmpty only picks up empty cells while = "" picks up BOTH empty cells and ""

Yep. Just another of the many joys of working with products in Office. It has a hard and fast rule that before you can do pretty much anything, you have to do something else first. And that rule is infinitely recursive. 🤔🤨😯😒😢🤬

At least with a VBA macro, I have much better testing capabilities. And if I find a bug/problem, fixing it fixes all of the calls.
 
Upvote 0

Forum statistics

Threads
1,215,081
Messages
6,123,016
Members
449,093
Latest member
ikke

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