Hi …
I have designed a report in such way that margin and margin% are the two custom columns in my report.
for the margin column data i used calculations in source expression property n its working fine…
But for margin% column i used below c/al code in sales line-OnafterGetRecord() trigger
IF “GM$” <> 0 THEN
GM := (“GM$” / “Unit Price”)*100
ELSE
GM := 0;
For some customers, margin is zero but where as Margin% column is displaying zeros in each field.
how to overcome the problem…
Thank u all…
Hi T.,
First, a point of order … please try not to post the same question more than once? This current post is almost identical to your previous post on http://dynamicsuser.net/forums/t/75645.aspx.
Now, to answer your question, don’t divide by zero. In your code, you’re dividing by the value of “Unit Price”, but you’re testing the value of “GM$” to be other than zero. You should be testing to ensure that “Unit Price” is not zero before executing the division operation.
Hi…
You should use this code to avoid error :
IF (“GM$” <> 0) AND (“Unit Price” <>0)THEN
GM := (“GM$” / “Unit Price”)*100
ELSE
GM := 0;
…and the correct answer is:
IF “Unit Price” <>0 THEN
GM := (“GM$” / “Unit Price”)*100
ELSE
GM := 0;