 1. ## Expression problem

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  Reply With Quote

2. ## RE: Expression problem

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  Reply With Quote

3. ## RE: Expression problem

David

Division by zero (mathematically) is undefined.

Your solution is the correct one to use.  Reply With Quote

4. ## RE: Expression problem

Not particularly important but since it appears that discount is a decimal (like .10)

(VENDORPRICE-(VENDORPRICE*DISCOUNT))

could be

(VENDORPRICE*(1-DISCOUNT))  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•