Skip to content

Math Expressions

Math expressions let you compute values inline on either side of a comparison, without needing to pre-compute fields in your data.

Math expressions support full nested arithmetic:

<expression> <comparison> <expression>

An expression can contain:

  • properties
  • literal numbers
  • +, -, *, /
  • natural-language aliases
  • parentheses
OperatorAccepted forms
addition+, plus, added to
subtraction-, minus, subtracted by
multiplication*, times, multiplied by
division/, divided by

The engine applies normal arithmetic precedence:

  1. parentheses
  2. multiplication and division
  3. addition and subtraction

This means multiplication happens before addition:

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

Use parentheses when you want a different grouping:

(__subtotal__ of **Order** + __tax__ of **Order**) * 2 is greater than 100
__subtotal__ of **Order** + __tax__ of **Order** is greater than 100

Aliases also work:

__subtotal__ of **Order** plus __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)

You can nest expressions and put arithmetic on both sides of the comparison:

(__used__ of **Quota** + __buffer__ of **Quota**) * 2 is less than __limit__ of **Quota** * 3 - 1

Interactive Example

Policy Rule
Test Data (JSON)

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

Interactive Example

Policy Rule
Test Data (JSON)

Every arithmetic step must resolve to numbers.

  • Non-numeric operands return a type error that includes the failing expression.
  • Division by zero returns an evaluation error that includes the full expression.
  • Execution traces expose the evaluated left-hand expression path and the final right-hand value, so the UI can explain what was compared.

Example errors:

Arithmetic expression $.Applicant.status resolved to string, but numeric operands are required
Division by zero in arithmetic expression ($.Student.total / ($.Student.count - $.Student.count))
CapabilitySupported
literal numbersyes
property referencesyes
math on the left sideyes
math on the right sideyes
nested expressionsyes
parenthesesyes
precedence (*// before +/-)yes
OperatorAccepted formsExample
addition+, plus, added to__subtotal__ of **Order** plus __tax__ of **Order** is greater than 50
subtraction-, minus, subtracted by__balance__ of **Account** minus __reserved__ of **Account** is at least 0
multiplication*, times, multiplied by__qty__ of **Order** times __price__ of **Order** is greater than 100
division/, divided by__revenue__ of **Store** divided by __costs__ of **Store** is greater than 1