IF...AND...OR...Statement

H

heater

I have the following formula, which does not work
=IF(OR(P28="Yes"),AND(W28=V28,D28-V28),OR(W28<V28,D28-W28,IF(P28="no",0))).
What I need is as follows:

If P28 is "Yes" and IF W28 is equal to V28, then D28 Minus V28, OR If P28 is
"Yes" and W28 is less than V28, then D28 Minus W28, If P28 is "No", then 0.
 
T

T. Valko

Try this:

=IF(P28="no",0,IF(AND(P28="yes",W28=V28),D28-V28,IF(AND(P28="yes",W28<V28),D28-W28,0)))
 
J

joeu2004

I have the following formula, which does not work
=IF(OR(P28="Yes"),AND(W28=V28,D28-V28),OR(W28<V28,D28-W28,IF(P28="no",0))).  
What I need is as follows:

If P28 is "Yes" and IF W28 is equal to V28, then D28 Minus V28, OR If P28 is
"Yes" and W28 is less than V28, then D28 Minus W28, If P28 is "No", then 0..

You could just formulate it exactly as you wrote it, namely:

=if(and(P28="yes",W28=V28), D28-V28, if(and(P28="yes",W28<V28), D28-
W28, 0))

Note: That returns zero even P28="yes", but W28>V28, as well as when
P28 is "no". You neglected to cover that condition. So it is unclear
exactly what you want.
 
R

Ron Rosenfeld

I have the following formula, which does not work
=IF(OR(P28="Yes"),AND(W28=V28,D28-V28),OR(W28<V28,D28-W28,IF(P28="no",0))).
What I need is as follows:

If P28 is "Yes" and IF W28 is equal to V28, then D28 Minus V28, OR If P28 is
"Yes" and W28 is less than V28, then D28 Minus W28, If P28 is "No", then 0.


In your explanation in the 2nd paragraph, your "OR" does not make sense to me.
Perhaps you really mean "ELSE" ??

If so, then I believe this will do what you describe:

=IF(AND(P28="Yes",W28=V28),D28-V28,
IF(AND(P28="Yes",W28<V28),D28-W28,
IF(P28="No",0)))

You realize, of course, there are logically possible conditions which are
unspecified. They will return FALSE.
--ron
 
T

Tyro

IF(P28="Yes",IF(W28<=V28,D28-V28,?),IF(P28="No",0,??))

You will have to fill in the ?'s. What do you want if W28 is greater than
V28 (?). What do you want if P28 is neither "Yes" or "No" (??)

Tyro
 
T

Tyro

Sorry, misread. Use this

=IF(P28="Yes",IF(W28=V28,D28-V28,IF(W28<V28,D28-W28,?),IF(P28="No",0,??))

You will have to fill in the ?'s. What do you want if W28 is greater than
V28 (?). What do you want if P28 is neither "Yes" nor "No" (??)

tyro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top