6 Replies Latest reply on Jan 18, 2017 7:29 AM by BruceRobertson

# IF/Else Statements Help

Good Morning,

trying to do an if/else statement and I keep being told the function can't be found, so i'm doing something wrong...can you help me determine what that is? all appears to look ok but obviously i'm missing something. Basically if there is a number in one field fill in the calculation, or if there is something in the other field fill in the calculation (the user will not fill in both fields, only one or the other).

• ###### 1. Re: IF/Else Statements Help

There is no such statement.

• ###### 2. Re: IF/Else Statements Help

Much better  if you do a Case

You should not have ( ) for your If, that is your problem

If(

Otherwise

)

and for

Case(

Otherwise

)

1 of 1 people found this helpful
• ###### 3. Re: IF/Else Statements Help

Thanks so much Johan, that was perfect!!!

• ###### 4. Re: IF/Else Statements Help

bmenendez,

Let me see if I can restructure it, using the Case function (there is no "If/Else If" function):

Case(

estimated_list_price > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100;

discount_percentage > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100

)

Note 1: Watch your order of operations in the results lines

Note 2: there could be a 3rd result in the Case statement:

Case(

estimated_list_price > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100;

discount_percentage > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100;

X     // X is whatever value or formula you desire if neither of the first two tests are true.

)

• ###### 5. Re: IF/Else Statements Help

It would appear that you confused the if FUNCTION with the IF script step here.

• ###### 6. Re: IF/Else Statements Help

Note that there are several problems with your IF statement.

A way to build the statement using the Case function has been demonstrated; and it is good to know how to do that.

But then we move on to some real problems with your underlying logic.

1. Numerical comparisons to text strings:

estimated_list_price > "0"

which should be

estimated_list_price > 0

(This was corrected in the other replies)

2. Logic problems

2.a

estimated_list_price > 0

You included no test for discount at this stage. So it could be empty; 0; or negative.

2.b

discount_percentage > 0;

If the first test didn't apply, this means that estimated_list_price is equal to 0 or less than 0.

(Including possibly empty)

So you are now working with a negative or empty estimated_list_price.

And a positive discount_percentage.

Example:

-100 - (-100 *25/100)

Case(

estimated_list_price > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100;

discount_percentage > 0;

estimated_list_price - estimated_list_price * discount_percentage / 100

)