# 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 |

Addition | {{add x y}} | {{add x 10}} |

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}} |

You can also use Numerical Calculation in Loops & Tables.

Example

{{#each line_items}}

Name: {{Name}}

Qty: {{Qty}}

Price: {{Price}}

Total: {{multiply Qty Price}}

{{/each}}

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

{{#each line_items}}

Sno: {{add @index 1}}

Name: {{Name}}

Qty: {{Qty}}

Price: {{Price}}

Total: {{multiply Qty Price}}

{{/each}}

Rounding of the numbers can be done using the helpers

**ceil**,**floor**, and**round**.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 |

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**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 |

Last modified 8mo ago