Arithmetic operations

You can perform simple addition, subtraction, multiplication and division between any two numbers using the following functions.

Note that these functions can be embedded into other functions.

That means they will return the result, either directly into the template for rendering as part of the response, or if they are enclosed in another function, then the result will be returned into that function.

Addition

{{ add  <number1> <number2> <format>}}

example:

{{ add this.cost this.markup '0.00' }}

Subtraction

{{ subtract <number1> <number2> <format> }}

example:

{{ subtract this.fullprice this.discount '0.00' }}

Multiplication

{{ multiply <number1> <number2> <format> }}

example:

{{ multiply this.quantity this.price '0.00' }}

Division

{{ divide <number1> <number2> <format> }}

example:

{{ divide this.discount '10' '0.00'}}

Summing Arrays

You can also sum an array of numbers using the following function:

{{ sum <array> <format> }}

example 1:

{{ sum (split (Request.Body 'jsonpath' '$.price[*]') ' ') '0.00' }}

example 2:

{{ sum myArrayOfNumbers '0.00' }}

Last updated