Find it truly hard to believe that Excel could treat a blank as if it were the value 0, for purpose of logic matching, but it appears to be so to me. Wonder if there is a workaround if you actually want to distinguish a blank cell from a cell with the value 0. Ideas?
Here are 3 SWITCH() formulas.
(1) =SWITCH(A1,,"zero/",1,"one",2,"two","else")
(2) =SWITCH(A1,0,"zero/",1,"one",2,"two","else")
(3) =SWITCH(JA1,"","zero/",1,"one",2,"two","else")
Now play with it by putting different values in A1.
If you put value 1 you get "one" as expected.
If you put value 2 you get "two" as expected.
If you put value 3 you get "else" as expected.
If you put value 0 you get "zero/" with formula(1) and formula(2). For formula(3) you get "else"
If you have cell A1 as blank, you get identical to the above, "zero/" for formula(1) and formula(2) and "else" for formula(3).
Hence it appears that excel is recognizing the blank cell as if it had a value in it, the value 0. Which i find rather shocking. How can this be?
If my requirement is to go to a different SWITCH branch as to if the cell is blank or 0...as both are valid (and different) observations in my data...any suggestions??
Of course the idea of finding some "dummy" value that is not otherwise valid in the data and substituting that for the blanks comes to mind. Very ugly and very difficult to maintain over time. I hope there is a better solution out there.
Here are 3 SWITCH() formulas.
(1) =SWITCH(A1,,"zero/",1,"one",2,"two","else")
(2) =SWITCH(A1,0,"zero/",1,"one",2,"two","else")
(3) =SWITCH(JA1,"","zero/",1,"one",2,"two","else")
Now play with it by putting different values in A1.
If you put value 1 you get "one" as expected.
If you put value 2 you get "two" as expected.
If you put value 3 you get "else" as expected.
If you put value 0 you get "zero/" with formula(1) and formula(2). For formula(3) you get "else"
If you have cell A1 as blank, you get identical to the above, "zero/" for formula(1) and formula(2) and "else" for formula(3).
Hence it appears that excel is recognizing the blank cell as if it had a value in it, the value 0. Which i find rather shocking. How can this be?
If my requirement is to go to a different SWITCH branch as to if the cell is blank or 0...as both are valid (and different) observations in my data...any suggestions??
Of course the idea of finding some "dummy" value that is not otherwise valid in the data and substituting that for the blanks comes to mind. Very ugly and very difficult to maintain over time. I hope there is a better solution out there.