Numerical Calculations
Want to calculate the numerical value for a field based on merge tokens? You can do so by entering your mathematical equation in the format below.
Operation
Syntax with two variables
Syntax with a variable & constant
Subtraction
{{subtract x y}}
{{subtract x 10}}
Multiply
{{multiply x y}}
{{multiply x 10}}
Divide
{{divide x y}}
{{divide x 10}}
Modulo
{{modulo x y}}
{{modulo x 10}}
Rounding of numbers
{{ceil x}} / {{floor x}} / {{round x}}

# Numerical Calculation in Loops & Tables

You can also use Numerical Calculation in Loops & Tables.
Example
1
{{#each line_items}}
2
3
Name: {{Name}}
4
Qty: {{Qty}}
5
Price: {{Price}}
6
Total: {{multiply Qty Price}}
7
8
{{/each}}
9
Copied!

## Incrementing @index in Loops & Tables

If you want to display the index of an element while iterating the loop, you can use {{@index}}. It usually starts from 0, so everytime you will have to increment it with 1. You can use add operator with @index.
Example
1
{{#each line_items}}
2
3
4
Name: {{Name}}
5
Qty: {{Qty}}
6
Price: {{Price}}
7
Total: {{multiply Qty Price}}
8
9
{{/each}}
10
Copied!

## Rounding of numbers

Rounding of the numbers can be done using the helpers ceil, floor, and round.

### Ceil

The helper ceil will round off the number to the nearest positive number which is greater than or equal to the give input number.
Example syntax
Input
Output
{{ceil number}}
198.58
199
{{ceil input}}
187.24
188

### Floor

The helper floor will round off the number to the nearest positive number which is lesser than or equal to the given input number.
Example syntax
Input
Output
{{floor number}}
198.58
198
{{floor input}}
187.24
187

### Round

Round helper will round of the given number in accordance with the value in it's decimal place. If the value in decimal places is greater than 50, then it will round of to the succeding number.
Example syntax
Input
Output
{{round number}}
198.58
199
{{round input}}
-187.74
-188