If statement

C

Cindi

I’m trying to do an IF OR statement, but I have something wrong. I currently
have:

Columns P, U and AB are formatted as a custom date. Column AC (destination
column) is a whole number.

=IF(OR($P348>0,+AB348-P348),"",IF($U348>0,+P348-U348,""))

What I’m trying to accomplish is, if column P is filled in then subtract AB
from P, but if U is filled, then subtract U from P, otherwise leave column AC
blank.

Can someone please help me?
 
B

Bernard Liengme

=IF($P348>0, AB348-P348),IF($U348>0,P348-U348,""))
This is read as: If P is greater than zero, return AB minus P
Else if U is great than 0, return P minus U
But is you want "to subtract AB from P" - to quote your message- then use

=IF($P348>0, P348-AB348),IF($U348>0,P348-U348,""))

You also use the phrase "if column P is filled ", so maybe P could have a
negative value or even a zero value and still be considered "filled", if so
=IF($P348<> "", P348-AB348),IF($U348<> "",P348-U348,""))
This reads: If P is not empty, then ,,,,, else if U is not empty

Please come back if clarifications are needed
best wishes
 
F

Fred Smith

Try it this way:
=IF($P348>0,P348-AB348,IF($U348>0,P348-U348,""))

This, as requested "subtracts AB from P". If this isn't really what you
want, then try:
=IF($P348>0,AB348-P348,IF($U348>0,P348-U348,""))

BTW, plus signs at the beginning of formulae are superfluous.

Regards,
Fred.
 
C

Cindi

Thanks.
--
JustLearning


Bernard Liengme said:
=IF($P348>0, AB348-P348),IF($U348>0,P348-U348,""))
This is read as: If P is greater than zero, return AB minus P
Else if U is great than 0, return P minus U
But is you want "to subtract AB from P" - to quote your message- then use

=IF($P348>0, P348-AB348),IF($U348>0,P348-U348,""))

You also use the phrase "if column P is filled ", so maybe P could have a
negative value or even a zero value and still be considered "filled", if so
=IF($P348<> "", P348-AB348),IF($U348<> "",P348-U348,""))
This reads: If P is not empty, then ,,,,, else if U is not empty

Please come back if clarifications are needed
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email
 
C

Cindi

Thanks. I forgot something. Sometimes column P is N/A. How do I add this
to the formula to make column AC N/A if this is true for column P?
 
B

Bernard Liengme

=if(ISNA($P348), NA(), IF($P348>0,P348-AB348,IF($U348>0,P348-U348,"")))

Note three closing ) at end
 
F

Fred Smith

In my opinion, the best way to handle N/A's is not to have them in the first
place. I would fix the formula that currently generates the N/A.

Regards,
Fred.
 
C

Cindi

Thank you for the help. Sorry can't get rid of the N/A, it's required for a
blank field.
 

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