Welcome,
How Can We Help You?

Add Calculations

Our calculation function enables you to perform calculations with variables within the text generation. You define the relevant variables using the text fields in the interview. You can, for example, calculate rents or wages etc. in the text part yourself and thus further automate and simplify your document generation.

Declare a Variable 

First, define the name of the variable in the questionnaire ::var[NAME_OF_THE_VARIABLE]. In case the name of the variable already exists in the template, a number is added. A text question can contain several text input fields as an answer so that you can declare several variables under one question. As an alternative to ::var you can also use ::variable or ::v

In use or preview mode, only numbers and no letters can be entered in the text input fields associated with the variables. Point and comma are reserved as decimal separators for numerical input, so the calculation function only recognizes them as such. Therefore, you cannot use periods or commas as thousand separators.

Tip

If you have a text field in which the user should only enter numbers, you can enter the variable in the text field as a command. You do not need a calculation function for this.

Then link the variable as a placeholder on the text page.

 

Determine a Calculation

On the text page (right side in the application), the calculation function can be inserted at the desired position. Type in the calculation operator ::calc [calculation with the previously defined variables] (you can also type ::c[ ]). Within the square brackets, you can perform the desired calculations with the variables defined previously. To do this, only the name of the variables must be entered. 

The following operators can be used: 

+ for the addition

for subtracting

/ for dividing

* for multiplying

% to get the modulo when dividing two variables (e.g. 12 % 5 = mod 2, 12 % 11 = mod 1, 12 % 3 = mod 0)

** to exponentiate a variable (e.g. 2**3 = 8, 3**2 = 9)

 

The "dot before dash"-principle applies. The calculation operator is automatically highlighted in green. In use or preview mode, the result is displayed directly instead of the calculation operator. You can of course also add brackets and numbers to the calculations to create even more complex calculations.

Subsequent Editing of Calculation Function

Move the cursor to the desired paragraph. Use the left/right key to move the cursor to the calculation function highlighted in green. As soon as the outline appears, you can use the backspace key on the keyboard to convert the function to plain text and edit it. When you have finished editing, the calculation function or operator should be highlighted green again. 

Options for the Calculation Function

For the calculation function (on the text page), options can be entered within the square brackets to format/modify the desired result. Use the left and right keys for subsequent editing (see Subsequent Editing of Calculation Functions).

fraction(2) - number of decimal places 

Tip

You can use "fraction(0)" to command that the number is rounded.

 

decimal(comma/point) - decimal separator comma or point 

thousands(comma/point/space/apostrophe/prime) - Representation of the separation of thousands sections - NOTE: Numbers in the questionnaire must always be entered without thousands separators. Only the output is formatted. 

words(12) - Display the number in words up to a maximum number. The language depends on the language selected in the template.

Example 1:  ::calc[a/b decimal(comma) thousands(point) fraction(3)]

Example 2: ::calc[a words(10000000)]

Editor:

Preview:

 
 

How to display the euro and cent amounts separately for monetary amounts:

With the %-operator it is possible to split the entered number into the part before and after the decimal point. When you have a variable a and the entered value is 10,50 then you can display this output: 10 euros and 50 cents. You just have to combine the following commands:
 
​::calculate[a - a%1 fraction(0) words(100000000)]​ euro and ::calculate[a%1 * 100 fraction(0) words(100)]​​​​ cent​s. 
 
Editor:

Preview:

 

How to declare a variable within a calculation:

A variable can be declared within the square brackets of the calculation function, to which the result of the calculation is assigned. Thus intermediate results can be stored in a variable and used later.  
variable(result1) - name of the variable, here " result1"
 
Example: ::calc[a+b variable(result1)]

Tip

You can also simply display the "intermediate result" again at another point. To do this, declare:

::calc[result1]

 

Serial Calculation

The calculation with serialized variables is of course also possible. First, create the variables and the calculation as described above. Link the text fields containing the serialized variables to the serial question. Then link the paragraph containing the calculation to the same serial question.

Then the serialized calculation will be executed in the document to be created. 

Tip

You can also use serialized and non-serialized variables mixed in these calculations.

 

Attention

Please do not combine the calculate function with the result as a variable (::calculate [a+b variable(result1)] with the other options shown.

 

 


 

 

 

Was this article helpful?

Can't find what you're looking for?

Our award-winning customer care team is here for you.

Contact Support