×
Menu
Index
  • Formulas

Formulas

 

Introduction

One of the ValueTYpes in an Assignment is Formula. If you make that choice, the content of the Value field is parsed like a formula. This formula's can contain brackets en in theory begin nested indefinitely. In basic a formula always consists of an Operator and a left and right Operand. The Operand can be a constant or a variable (element), a subformula (between brackets) or a Formula Function.
 
For example:
 
1+2
 
Is a formula with 2 operands (1 and 2) and an operator (+). And:
 
1+(3*4)
 
Is a formula with 2 Operands, where the right Operand is a subformula. The subformula is a formula with 2 Operands (3 and 4) and an Operator (+).
 
Below we see an example of a formula using a Formula Function as an Operand:
 
1+MAX(3;4)
 
In this case the maximum value of 3 and 4 is added to the constant 1. The result will obviously be 5. The parameters of the Formula Function can be formulas, variables and Formula Functions, so complex constructions can be built.
 
An example of a formula with a variable Operand is:
 
[Premium]+100
 
The value of Premium will be added with 100. Watch out that Premium should reside in the current path. If CA_VERZSOM should be in another path, this path should be used in the formula. Example:
 
[./Contract/Policy/Premium]+100
 

Operands

Constants

When an Operand is not a Formula Function, an Elementname or a Subformula, it is being used as a constant. At first SoftRules® checks if the constant is a number, after that if it's a date and at last it will be seen as a string. If you add something to a string, that will be seen as a concatenation. Example:
 
Soft + Rules
 
Will become: SoftRules
 
And:
 
10 + eleven
 
Will become: 10eleven. This because the right operand is not a number and you can't add a number and a string.
 

Variables and Elements

 
Variables and Elements will always be placed between square brackets. If they are not between brackets, the Operand will be seen as a string.
 

Operators

There are 2 groups of Operators, mathematical and logical. Mathematical Operators always result in a value (integer, float or sometimes a string) while logical Operators always result in True or False. In these formulas, the result of logical Operators are the number 1 (for True) and 0 (for False).
 

Mathematical Operators

^ (Raise to a power)
 
Example:
10^2
Result: 100
+ (Sum)
 
Example:
10+2
Result: 12
* (Multiply)
 
Example:
10*2
Result: 20
/ (Divide)
 
Example:
10/2
Result: 5
- (Subtract)
 
Example:
10-2
Result: 8
MOD (Modulo)
 
Example:
10 MOD 2
Result: 0
7 MOD 3
Result: 1
DIV (Divide)
 
Example:
10 DIV 2
Result: 5
7 DIV 3
Result: 2
 

Logical Operators

== of = (Equal)
 
Example:
2==3 of 2=3
Result: 0
2==2 of 2=2
Result: 1
!= of <> (Not equal)
 
Example:
2!=3 of 2<>3
Result: 1
2!=2 of 2<>2
Result: 0
<= (Less than or equal)
 
Example:
2<=3
Result: 1
1<=2
Result: 0
>= (Greater than or equal)
 
Example:
2>=3
Result: 0
2>=2
Result: 1
|| (OR)
 
Example: Result = A || B
A
B
Result
0
0
0
0
1
1
1
0
1
1
1
1
&& (AND)
 
Example: Result = A && B
A
B
Result
0
0
0
0
1
0
1
0
0
1
1
1
 
 

Value editor

You can doubleclick all field in SoftRules®  that accept Formula type Values and the Value Editor will popup. Use this to build your Formulas.