I have the following expression in a calculated field in the table's Field rules):
RETAIL_PRICE-CUST_PRICE*QTY
It returns a negative number. For instance; 18.45-14.76*3 = -25.83 instead of 11.07
What do I need to change?
Thanks,
kenn
Printable View
I have the following expression in a calculated field in the table's Field rules):
RETAIL_PRICE-CUST_PRICE*QTY
It returns a negative number. For instance; 18.45-14.76*3 = -25.83 instead of 11.07
What do I need to change?
Thanks,
kenn
Tell Alpha in what order to evaluate the expression.
(RETAIL_PRICE-CUST_PRICE)*QTY
Of Course!!! Oh Dah!!!!
Thanks Stan,
kenn
For any who may be 'looking in' on this thread,
Ken's original expression gave the wrong number because the multiplication operation takes precedence over the subtraction. The expression is not evaluated from left to right. It's evaluated in order by arithmetic operator precedence.
This is explained in the User's Guide at p 207 in the discussion of 'Arithmetic Operator Precedence'.
Interestingly, the example give in the book says:
3 + 4 * 5 is equivalent to 3 + (4 * 5) since the multiplication operation takes precedence over the addition operator.
-- tom