Operators
Operators are used in formulas that you create on the Formula Editor Dialog Box, which is called from the Import Scenarios (SM206025) and Export Scenarios (SM207025) forms.
To add operators to the formula, you can enter them directly in the Formula Text pane of the dialog box or select them from the list of formula components available within the dialog box. (Select an operator type to view the list of operators of the type, and then select an operator.) To specify the operands for operators, you can type them in the Formula Text pane or select them from the list of external or internal fields provided within the Formula Editor dialog box.
This article describes and provides examples of the operators you can use in formulas, broken down by operator type.
Overview of Operators
There are two types of operators: unary and binary. Unary operators are applicable to only one operand, while binary operators require two operands.
In general, expressions are evaluated from left to right with the following order of precedence:
- Logical Operators: Not, And, Or
- Comparison Operators: =, <>, , <=, >=
- Arithmetic Operators: -, *, /, Mod, +, -
Arithmetic Operators
Arithmetic operators, which are listed below, take numerical values as their operands and return a single numerical value.
Operator | Description and Example |
---|---|
+ |
Adds the two operands and returns the result. If at least one operand is a string, this operator returns a concatenated string. Example:
In this example, the |
- |
Subtracts the second operand from the first. Example:
In this example, the |
* |
Multiplies the two operands. Example:
In this example, the |
/ |
Yields the quotient of the operands, which is the first operand divided by the second. Example:
In this example, the |
Mod (Modulus) |
Divides the first integer operand by the second integer operand and returns the remainder, rounded to the nearest integer. Example:
In this example, the |
Logical operators
Logical operators evaluate one or two Boolean expressions and return a Boolean result (True or False). Because these operators evaluate only Boolean expressions, you must use elements whose only values are True and False (typically check boxes and radio buttons). The logical operators are listed below.
Operator | Description and Example |
---|---|
And |
Performs logical conjunction on two Boolean expressions: returns True if and only if both expressions evaluate to True; in other cases, returns False. Example:
In this example, the |
Or |
Performs logical disjunction on two Boolean expressions: returns True if at least one expression evaluates to True; returns False if neither expression evaluates to True. Example:
|
Not |
Performs logical negation on a Boolean expression: returns True if and only if the operand is False. Logical negation is an unary operator. Example:
In this example, the |
Comparison Operators
Comparison operators compare two expressions and return a Boolean value (True or False) that represents the result of the comparison. This group of operators includes the following operators.
Operator | Description and Example |
---|---|
= |
Returns True if operands are equal. Example:
In this example, the |
<> |
Returns True if operands are not equal. Example:
In this example, the |
< |
Returns True if the first operand is less than the second one. Example:
In this example, the |
> |
Returns True if the first operand is greater than the second one. Example:
In this example, the |
<= |
Returns True if the first operand is less than or equal to the second operand. Example:
In this example, |
>= |
Returns True if the first operand is greater than or equal to the second operand. Example:
In this example, the |
Other Operators
This miscellaneous group of operators includes the following operators and constants.
Operator | Description and Example |
---|---|
In |
An operator that returns True if the second operand (a string) contains the first operand (which is also a string). Example:
In this example, the |
True |
A binary constant used as an operand in logical expressions. Example:
|
False |
A binary constant used as an operand in logical expressions. Example:
|
Null |
A special value used as an operand in logical expressions; designates an undefined value. Example:
|