Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: formula error Post Reply Post New Topic
Author Message
Wood
Newbie
Newbie


Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
Quote Wood Replybullet Topic: formula error
    Posted: 03 Oct 2016 at 7:43am
The below returns the correct calculation for the second and third condition but it will only return 0 for the first even though the records are included in the report. What am I missing?


if{V_ORDER_HIST_LINE.USER_1}="123"Then
formula={@Extension}*0.01
elseif{V_ORDER_HIST_HEAD.USER_1}="456"Then
formula={@Extension}*0.01
elseif{V_ORDER_HIST_HEAD.USER_1}="789"Then
formula={@Extension}*0.006
End if
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Oct 2016 at 9:03am
First off I am not sure why you did not write the formula like this.


if{V_ORDER_HIST_LINE.USER_1}="123" or {V_ORDER_HIST_HEAD.USER_1}="456" then  formula={@Extension}*0.01 else
if{V_ORDER_HIST_HEAD.USER_1}="789"Then
formula={@Extension}*0.006  end if

Also we do not know what {@Extension} does.  It may be a data issue.
IP IP Logged
Wood
Newbie
Newbie


Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
Quote Wood Replybullet Posted: 03 Oct 2016 at 9:10am
The reason I did not add the "or" as in your formula below is that not all the formulas are *0.01 some will be 0.006. Sorry I left out that detail.

The {@extension} is the results of qty * $ in the report. So I am taking a result of a qty shipped times an amount and then calculating the commission.

Does that make sense?
Does that {@extension} effect the formula in an adverse way?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Oct 2016 at 12:10pm
In the example you showed.  The first two lines are multiplied by the same value.  It would make it easier to read and maintain if all values that are being multiplied by the same value be in the same if statement.

So have you checked the data to see if when {V_ORDER_HIST_LINE.USER_1}="123" that {@extension} returns a non-zero value?
IP IP Logged
Wood
Newbie
Newbie


Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
Quote Wood Replybullet Posted: 03 Oct 2016 at 12:33pm
Success ! I was using the wrong field on the one condition. They were very close in description and I had chosen the wrong one. Your suggestion to see if it returns a non-zero value made me find it.

Thank you !
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 04 Oct 2016 at 3:57am
Glad you got it.  I will not say how many times I have made a similar error.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.