Skip to content

Math Expressions

Math expressions let you compute a value inline and compare the result, without needing to pre-compute fields in your data.

A math expression combines two operands with an arithmetic operator:

<operand> <operator> <operand> <comparison>

Operands can be properties or literal numbers. Supported operators are +, -, *, and /.

__subtotal__ of **Order** + __tax__ of **Order** is greater than 100

Interactive Example

Policy Rule
Test Data (JSON)

Mix a property with a literal:

Interactive Example

Policy Rule
Test Data (JSON)
__balance__ of **Account** - __pending__ of **Account** is at least 0

Interactive Example

Policy Rule
Test Data (JSON)
__quantity__ of **Order** * __unit_price__ of **Order** is greater than 1000

Interactive Example

Policy Rule
Test Data (JSON)
__revenue__ of **Store** / __expenses__ of **Store** is greater than 1.5

Interactive Example

Policy Rule
Test Data (JSON)

Division by zero produces an evaluation error. Guard against it with an appropriate condition or ensure your data is valid before passing it to the engine.

Math expressions can be combined with and and or like any other condition:

Interactive Example

Policy Rule
Test Data (JSON)
OperatorExample
+__subtotal__ of **Order** + __tax__ of **Order** is greater than 50
-__balance__ of **Account** - __reserved__ of **Account** is at least 0
*__qty__ of **Order** * __price__ of **Order** is greater than 100
/__revenue__ of **Store** / __costs__ of **Store** is greater than 1

Both operands must be numeric. Using a non-numeric property in a math expression will produce a type error.