PDA

View Full Version : Expression problem


ABC123

David
01-22-2005, 09:41 AM
I have an expression defined in field rules under the field called cost;

((VENDORPRICE-(VENDORPRICE*DISCOUNT))/UNIT)

My result for example is .01811

When I add this to the end of the above expression;
+(FREIGHT/FREIGHTUNIT)
if the freightunit is blank, my value is 0. If I put a 1 in the freightunit then my value is .01811
Sometimes there is no freight so nothing is entered in the freight and freighunit, so then my cost becomes 0. What can I do to the expression so I don't have to enter 1 in the freightunit when there is no freight? When I add freight and freightunit it works correctly.
What am I doing wrong?

Thanks,
DAvid

David
01-22-2005, 10:10 AM
I fixed my problem, I'm not sure why, but I was dividing 0 by 0 and when you do that on a calculator you get an error. Anything divided by itself is 1 and 0 divided by 0 is not 1.
Here is my formula;

(VENDORPRICE-(VENDORPRICE*DISCOUNT))/UNIT+IF(FREIGHTUNIT=0,0,FREIGHT/FREIGHTUNIT)

David

Al Buchholz
01-22-2005, 11:29 AM
David

Division by zero (mathematically) is undefined.

Your solution is the correct one to use.

Stan Mathews
01-22-2005, 12:37 PM
Not particularly important but since it appears that discount is a decimal (like .10)

(VENDORPRICE-(VENDORPRICE*DISCOUNT))

could be

(VENDORPRICE*(1-DISCOUNT))