Sam
Sam

Reputation: 736

IF condition when value is not 0 and not empty

I have the following formula

=IF((AND($R$29="12+",D16<>0)),D2, IF((AND($R$29="12+",D16<>"")),D2,""))

and right now

But on the cell that my formula is at I get the value of D2 rather than an empty cell and I'm not sure why as I told the formula to show an empty cell if there is nothing on D16 and R29 = 12+.

Can somebody help me figure out what I am doing wrong?

Upvotes: 0

Views: 5156

Answers (1)

amitklein
amitklein

Reputation: 1395

The excel if statement is =IF (logical_test, [value_if_true], [value_if_false])

in your code you switched the true with the false

so right now in the =IF((AND($R$29="12+",D16<>0)),D2,IF((AND($R$29="12+",D16<>"")),D2,""))

The first part returns true because (AND($R$29="12+",D16<>0) is actually true, so is does the true part of the statement witch is D2

The correct formula should be:

=IF((AND($R$29="12+",D16<>0)),IF((AND($R$29="12+",D16<>"")),"",D2),D2)

Upvotes: 1

Related Questions