Math Expression Documentation
Version: 1.1.1
Retrieved: 2025-10-09 15:16:02
Math Expression
Allows you to do math operations written as a template, has support for basic functions as well as using message properties in the template.
The module is designed to be located in the middle of a flow.
Settings
Accessing properties in the math expression from incoming messages are done by writing the property within {}.
| Name | Requirements | Purpose | Default |
|---|---|---|---|
| Target Property | String with length 1-64 | Property that will contain the result of the math expression. | data.result |
| Expression | String with length 1-1024 | The math expression to execute in the module |
Input
The input requirement is that all the properties that is used in Expression exists on the message, otherwise no restrictions.
Output
Same message as input with appended property that is set in Target Property, which contains the result from the Expression specifications.
Supported Functions
| Name | Description | Usage | Result |
|---|---|---|---|
| Abs | Returns the absolute value of a specified number. | Abs(-1) | 1 |
| Acos | Returns the angle whose cosine is the specified number. | Acos(1) | 0 |
| Asin | Returns the angle whose sine is the specified number. | Asin(0) | 0 |
| Atan | Returns the angle whose tangent is the specified number. | Atan(0) | 0 |
| Ceiling | Returns the smallest integer greater than or equal to the specified number. | Ceiling(1.5) | 2 |
| Cos | Returns the cosine of the specified angle. | Cos(0) | 1 |
| Exp | Returns e raised to the specified power. | Exp(0) | 1 |
| Floor | Returns the largest integer less than or equal to the specified number. | Floor(1.5) | 1 |
| IEEERemainder | Returns the remainder resulting from the division of a specified number by another specified number. | IEEERemainder(3, 2) | -1 |
| Log | Returns the logarithm of a specified number. | Log(1, 10) | 0 |
| Log10 | Returns the base 10 logarithm of a specified number. | Log10(1) | 0 |
| Max | Returns the larger of two specified numbers. | Max(1, 2) | 2 |
| Min | Returns the smaller of two numbers. | Min(1, 2) | 1 |
| Pow | Returns a specified number raised to the specified power. | Pow(3, 2) | 9 |
| Round | Rounds a value to the nearest integer or specified number of decimal places. The mid number behaviour can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object. | Round(3.222, 2) | 3.22 |
| Sign | Returns a value indicating the sign of a number. | Sign(-10) | -1 |
| Sin | Returns the sine of the specified angle. | Sin(0) | 0 |
| Sqrt | Returns the square root of a specified number. | Sqrt(4) | 2 |
| Tan | Returns the tangent of the specified angle. | Tan(0) | 0 |
| Truncate | Calculates the integral part of a number. | Truncate(1.7) | 1 |
Additional Functions
| Name | Description | Usage | Result |
|---|---|---|---|
| if | Returns a value based on a condition. | if(3 % 2 = 1, 'value is true', 'value is false') | 'value is true' |
The values to return can be strings, formulas, conditions or another if statement.
Examples
Example 1 - Basic expression
# Settings:
Expression = (10+11)/3
Target Property = result
# Incoming message:
Does not matter, not using the input
# Outgoing message:
{
"result": 7
}
Example 2 - Using data on incoming message
Calculating Newton meter from kw and rpm
# Settings:
Expression = (9550*{engine.kw})/{engine.rpm}
Target Property = engine.nm
# Incoming message:
{
engine:
{
"rpm": 3100,
"kw": 198
}
}
# Outgoing message:
{
"engine":
{
"rpm": 3100,
"kw": 198,
"nm": 609.97
}
}
Example 3 - Using expressions on incoming message
Calculating fahrenheit from celcius using expressions from the incoming message in combination with a expression in the settings.
# Settings:
Expression = {expression}+32
Target Property = data.fahrenheit
# Incoming message:
{
"expression": "{data.celcius}*9/5",
"data": {
"celcius": 34
}
}
# Outgoing message:
{
"expression": "{data.celcius}*9/5",
"data": {
"celcius": 23,
"fahrenheit": 73.4
}
}
Operators
Expressions can be combined using operators. Each operator has a precedence priority. Here is the list of those expression's priority.
- primary
- unary
- multiplicative
- additive
- relational
- logical
Logical
These operators can do some logical comparison between other expressions: or, || and, &&
true or false and true
The and operator has higher priority than the or operator, thus in the example above, false and true is evaluated first.
Relational
=, ==, !=, <> <, <=, >, >=
1 < 2
Additive
+, -
1 + 2 - 3
Multiplicative
*, /, %
1 * 2 % 3
Bitwise
& (bitwise and), | (bitwise or), ^(bitwise xor), << (left shift), >>(right shift)
2 >> 3
Unary
!, not, -, ~ (bitwise not)
not true
Primary
(, ) values
2 * ( 3 + 2 )
Search Documentation
Process & Analyze
Calculations & Statistics