Formulas
Formulas are used in several places in the configurator and the thing they have in common is the use of variables to perform calculations. The formulas are basically used in two ways:
- To calculate values
- To analyze if a term is true or false.
The different formulas you can create are determined by the different types of variables that exist. These can be Text, Number, Boolean, and Date. The different types of formulas that exist are:
- Time formulas – Used for operations to calculate unit times and setup times.
- Quantity formulas – Used to calculate quantity and setup quantity for materials.
- Price formulas – Used to calculate prices for included/incorporated parts and can also be used for flexible pricing of main parts (the parts you configure).
- Variable formulas – Used on variables to calculate values on variables.
- Instruction formulas – Used to calculate values which should be displayed in an instruction.
- Rule formulas – Used in rules when you want to create terms which apply variables. These formulas always result in "true" or "false".
You create the formulas in a formula editor on the records when formulas can be created. You access the formula editor by clicking the button Formula . When there already exists a saved formula, you will see a different symbol on the button
.
The formulas are constructed as logical and mathematical expressions of available variables, operators, terms, and functions.
For all different types of formulas (except for variable formulas and rule formulas) you add one or multiple configuration groups in the formula editor (to see the available variables) and you select/add a formula number for each configuration group. You can add more formula numbers and create different formulas for these in the formula editor. You can also choose to use the same formula number for multiple configuration groups.
Different validations are made in the formula editor. Validations are for example made to make sure the result of the formula is of the right type, e.g. a number or a text. Validations are made to see that the entered variables exist, for example if a formula is copied from one material row to another material row and that a configuration group is selected in the formula editor. If validation errors occur, what is wrong will be displayed in red text. Then you cannot save the formula using the OK button in the formula editor until you have corrected the problem.

For a time formula or quantity formula for operation or material in BOM and routing, you can choose one of three different formula functions to be taken into consideration when registering an order. These are to multiply, add, or replace the regular value of unit time/setup time and the quantity/setup quantity with the result of the formula. You select this in the top left part of the formula editor.
For a price formula on a part in the part register, the formula function is always to multiply the regular value on the part's price by the result of the formula. That function cannot be changed in the formula editor.
For a variable formula on a variable, the formula function is always to give the variable the value of the formula's result.
For a rule formula in a rule definition, the formula function is always to give the variable the value "true" or "false" from the formula's result.
For a instruction formula in a configured instruction, the formula function is always to give the variable the value of the formula's result.

A variable is written in square brackets [ ]. For example, you have a variable code "Height" for height and a variable code "Width" for width. You then wish to create a rule in a configuration which excludes or includes options if the "height x width is greater than 100000". Then you write a formula in the rule definition as follows "[Height]*[Width]>100000".
Variables are also case sensitive. This means the variable code "Width" is not the same as the variable code "width".
In the formula editor there is something called "IntelliSense". This helps you write formulas quickly and it also prevents you from writing incorrect variable codes. It gives you suggestions of variables and functions as you are typing in the formula editor. To get suggestions of variables you can use you can enter the left square bracket "[". Then a list of the variables available in the selected configuration group will be shown.
If you instead enter a letter you will get suggestions of all functions starting with that specific letter. For example, if you enter an "s" you will get a list showing you the functions starting with "S".
You select variable or function using the arrow keys and press Enter to insert it in the formula. You can also double click the row to insert it. To the right in the list you will see a description of the marked variable or function.
Using the key combination Ctrl + space you access all available variables and all function. Using the key combination Alt Gr + 8 you will only access all variables.
Values in variables of the type Text are written using apostrophes, for example Blue is written 'Blue'. Values in variables of the type Date are written surrounded by number signs, also called hash. For example, the date 2018-11-14 is written as #2018-11-14#.
In addition to variables and functions, you can also use the below operators and terms in formulas. For operators and terms you will not get suggestions. These have to be entered manually in the formula.
Operators | Terms |
---|---|
+ - * / % ( ) |
< > = <> if(condition, true, false) and or not |

In configured instructions (the CI button) on operations and material in BOM and routing as well as for options in option lists, you can also enter variables and formulas using drag and drop. There you mark the variable you want in the variable table or the formula you want in the formula table, and then you drag it using the mouse pointer to the place in the instruction where you want it.
Variables and formulas can also be entered manually within square brackets in configured instructions. A variable is written as [v:variable code]. A formula is written as [f:formula name]. Please note! You should start with "v:" or "f:" within the square brackets. A validation is made to see that a variable or formula is available when you manually enter them.