IF statement returning "0" on blank cells

How do I get an IF statement to display a blank cell instead of "0" when it encounters an empty cell in the formula?


I want E2 to be blank is B2 is blank


In Cell E2

=IF($A2="media",B,"")



A

B

C

D

E

F

G

1

media

0.1%

0.5%

1.5%

0.1%

0.5%

1.5%

2

media




0.0%

0.0%

0.0%

Posted on Aug 25, 2016 3:09 PM

Reply
8 replies

Aug 25, 2016 4:52 PM in response to kilograham

Hi kilograham,


My preferred approach would be to hide the 0% with a conditional highlighting rule:

User uploaded file

If the value is 0 then the text is white. I tend to allow a very pale grey when I do this for myself.


Another approach would be to test B2 before you proceed with your original IF

E3= IF(LEN(B>0),IF($A3="media",B,""),"")

This tests if there is a character in B.


quinn

Aug 26, 2016 9:22 AM in response to kilograham

kilograham wrote:


your logic is smarter than me. Can you explain what you did?



Sure. I actually find the logic easier to follow than nested ifs, which sometimes can get confusing.


All the formula says is:


If A2 contains something other than "media" or B2 is blank then put a blank. Otherwise, put the value that appears in B2.


The OR(A2<>"media",B2="") is the part that tests whether A2 has something other than "media" or B2 is blank.


Put that part as the <test> in the usual IF(<test>,<value-if-true>,<value-if-false>) and you get:


=IF(OR(A2<>"media",B2=""),"",B2)


Short and sweet.


If you haven't done so already already, you can check out Formulas and Functions Help for IF. (You can also get there via Help > Formulas and Functions Help in your menu.)


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

IF statement returning "0" on blank cells

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.