Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Nested Formula 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: Nested Formula
    Posted: 16 Aug 2016 at 7:32am
I am trying to run the following nested formula and the second and third if/thens work but the first one "Board" returns 0. I do not see the error. The selection section will find "Board" and return a good report but the formula={@Extension}*0.03 in this formula returns 0


if{V_ORDER_HIST_LINE.USER_1}="Board"then
formula={@Extension}*0.03
elseif{V_ORDER_HIST_LINE.USER_1}="Boy"then
formula={@Extension}*0.01
elseif{V_ORDER_HIST_HEAD.USER_1}="Dog"Then
formula={@Extension}*0.01
elseif{V_ORDER_HIST_HEAD.USER_1}="Tail"Then
formula={@Extension}*0.006
elseif{V_ORDER_HIST_HEAD.USER_1}="Hair"Then
formula={@Extension}*0.05
elseif{V_ORDER_HIST_HEAD.USER_1}="Car"Then
formula={@Extension}*0.02
elseif{V_ORDER_HIST_HEAD.USER_1}="Step"Then
formula={@Extension}*0.01
elseif{V_ORDER_HIST_HEAD.USER_1}="World"Then
formula={@Extension}*0.01
End if
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 Aug 2016 at 7:55am
Personally I prefer to use the switch function instead of nested if's , example:

switch({V_ORDER_HIST_LINE.USER_1}="Board", formula={@Extension}*0.03, {V_ORDER_HIST_LINE.USER_1}="Boy", formula={@Extension}*0.01, etc.)
IP IP Logged
Wood
Newbie
Newbie


Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
Quote Wood Replybullet Posted: 16 Aug 2016 at 8:28am
Thank you for the response. I received an error,

"A number, currency amount, boolean, date, time, date-time, or string is required here."

and it hi-lights the first instance of formula.

switch({V_ORDER_HIST_LINE.USER_1}="Board",formula={@Extension}*0.03)

Sorry I am not a programmer.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 Aug 2016 at 12:26pm
Opps did not notice that you were using BASIC format.  It should look like this.

formula = switch({V_ORDER_HIST_LINE.USER_1}="Board", {@Extension}*0.03, {V_ORDER_HIST_LINE.USER_1}="Boy", {@Extension}*0.01, etc.)


IP IP Logged
Wood
Newbie
Newbie


Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
Quote Wood Replybullet Posted: 17 Aug 2016 at 4:00am
Thank you for your reply! This works great.
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.