Designers > K2 Designer for Visual Studio > Design Tools > Inline Functions > Function Browser > Expression > Build Expression > General Operators | Send feedback |
Contextualized Assistance: |
Operator | Description | Example |
---|---|---|
& | Use to join two or more strings or fields. | Input Value: FirstName & " " & LastName Result: "John Doe" |
+ | Use to add numbers or decimals. | Input Value: 1 + 1.1 Result: 2.1 |
- | Use to subtract numbers or decimals. | Input Value: 1.1 – 1 Result: 0.1 |
* | Use to multiply numbers or decimals. | Input Value: 1 * 1.1 Result: 1.1 |
/ | Use to divide numbers or decimals. This will always result in a decimal. |
Input Value: 1 / 1.1. Result: 0.909 |
mod | Use to return the remainder after a division. |
Input Value: 16 mod 5 Result: 1 |
pow | Use to apply an exponent (power of) to preceding number. | Input Value: 2 pow 3 Result: 8 |
= | Use to determine if two numbers or fields are equal. Returns Boolean. | Input Value: Price = 500 Result: True |
<> | Use to determine if two numbers are not equal. Returns Boolean. | Input Value: Price <> 400 Result: True |
> | Use to determine if number on left is greater than number on right. Returns Boolean. | Input Value: 2>1 Result: True |
< | Use to determine if number on left is less than number on right. Returns Boolean. | Input Value: 1<2 Result: True |
>= | Use to determine if number on left is greater than or equal to number on right. Returns Boolean. | Input Value: 1>=1 Result: True |
<= | Use to determine if number on left is less than or equal to number on right. Returns Boolean. | Input Value: 1<=1 Result: True |
And | Performed on two Boolean values. Returns True if both values are True, and False if either value is False. | Input Value: True Input Value: False Result: False |
Or | Performed on two Boolean values. Returns True if either value is True, False if both values are False. | Input Value: True Input Value: False Result: True |
Xor | Performed on two Boolean values. Returns True if one and only one value is True. | Input Value: True Input Value: True Result: False |
Not | Negates (Boolean) a value. | Input Value:not (1=1) Result: False |
(…) | Surrounds selected items with parentheses. Use for order of operations. | Input Value:(5 + 5) * (4 + 6) Result: 100 |
- (unary) | Negates (numeric) a value. | Input Value:-(5 + 5) Result: -10 |
Brackets behave exactly like they do in mathematics. They force a certain part of the expression to be evaluated before another one is evaluated. You can also use brackets for Boolean and comparison terms. For example:
Boolean |
Copy Code
|
---|---|
(true and true) or (false and true) = true or (false and true) = true or false = true |
or
Comparison |
Copy Code
|
---|---|
(5 > 6) or (6 > 5) = false or (6 > 5) = false or true = true |
Not simply changes true to false; and false to true.
Copy Code
|
|
---|---|
not true or false = false or false = false |
Boolean operators simply combine two true/false values in certain ways. These ONLY work on true/false (Boolean) values. They are and, or and xor. The following tables give the outcomes.
And (both must be true):
Value 1 | Value 2 | Outcome |
---|---|---|
True | False | False |
True | True | True |
False | False | False |
False | True | False |
Or (either value can be true):
Value 1 | Value 2 | Outcome |
---|---|---|
True | False | True |
True | True | True |
False | False | False |
False | True | True |
Xor (Exclusive or, either can be true, but not both):
Value 1 | Value 2 | Outcome |
---|---|---|
True | False | True |
True | True | False |
False | False | False |
False | True | True |
The comparison operators determine the size relation between two values. They can be used on numbers, text, dates and time spans.
The multiply operators are * (multiply), / (divide), mod (modulus) and pow (power). These operators only work on number values. Divide will always result in a decimal. Multiply, modulus and power will result in the most precise type:
There are the two mathematical addition operators (+ and -); as well as the string addition (concatenation) operator &. These can also be used on dates and time spans. Please note that the following expression will not result in a concatenation in the expression builder (unlike the K2 text box):
Hello [FieldPart]
It is required to use the string addition operator to concatenate strings.
The negate operator simply turns a number value into it’s negative. For instance:
Copy Code
|
|
---|---|
-(1 + 1) = -2 |