Author |
Message |
Wood
Newbie
Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
|
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 Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
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 Logged |
|
Wood
Newbie
Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
|
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 Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
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 Logged |
|
Wood
Newbie
Joined: 04 Aug 2016
Location: United States
Online Status: Offline
Posts: 9
|
Posted: 17 Aug 2016 at 4:00am |
Thank you for your reply! This works great.
|
IP Logged |
|
|