Math Operations
You can do simple math using the math formatters, add, sub, mul, div and mod.
For example [[text:2:add 4]] returns a value of 6.
Or let's say the variable "counter" contains 6, here are some simple examples:
[[var:counter:sub 1]] will return 5. [[var:counter:add 1]] will return 7. [[var:counter:mul 3]] will return 18. [[var:counter:div 3]] will return 2. [[var:counter:mod 4]] will return 2. The remainder of 6 divided by 4 is 2.
IMPORTANT: You cannot directly use Decimal numbers for these operations.
For example you cannot use :
[[var:counter:mul 3.5]]
But you can use [[var:counter:mul 3]]
To use Decimal / Floating point and execute more complex math operations, use JavaScript.Multiple Operations: Pipe
Also, remember that you can string formatters together using the pipe "|" character (shift-backslash on American computer keyboards), such as
[[var:counter:add 1|mul 3]] calculates (6 + 1) x 3, or 21.
IMPORTANT: There are NO space around the pipe "|" symbol.![]()
Learn More
- Formatters
- Introduction to Expressions