Computed Values
Computed values let you name an arithmetic expression once and reuse it later in the same policy.
They are useful when:
- the same calculation appears in multiple conditions
- you want a long expression to have a readable name
- you want to break a policy into smaller numeric steps
Syntax
Section titled “Syntax”Define a computed value with :=:
total_requested := **requestedUnits** plus **reservedUnits**.Reference it later with @name:
A **request** is allowed
if @total_requested is less than **monthlyAllowance**.:= defines a named calculation in the policy. It is not a mutable variable.
Basic Example
Section titled “Basic Example”Interactive Example
Policy Rule
Test Data (JSON)
Chaining Computed Values
Section titled “Chaining Computed Values”Computed values can reference earlier computed values:
squared_score := **score** power of 2.
rounded_score := round @squared_score to 2 places.
A **Applicant** is approved
if @rounded_score is greater than 49.Aggregate Expressions
Section titled “Aggregate Expressions”Computed values work with aggregate expressions too:
order_total := sum of __prices__ of **Order**.
average_price := average of __prices__ of **Order**.
A **Order** qualifies for review
if @order_total is greater than 100
and @average_price is greater than 20.Input Sources
Section titled “Input Sources”Computed values can read from:
- selector properties like
**score** - property paths like
__prices__ of **Order** - other computed values like
@order_total - inline arithmetic and math functions
Natural Math Syntax
Section titled “Natural Math Syntax”Computed values support the same arithmetic forms as rule conditions:
rounded := round **score** to 2 places.
total := sum of __scores__ of **Report**.
bounded := clamp(@total, 0, 100).Numeric Strings
Section titled “Numeric Strings”If your input data contains numeric strings, arithmetic still works:
incremented := **score** plus 1.
rounded := round **score** to 1 place.with input like:
{ "score": "12.5"}This also applies to array aggregates such as sum of and average of.
Relationship to Labels
Section titled “Relationship to Labels”Computed values defined with := are separate from boolean rule labels like §ageCheck.
- use
:=when you want a reusable numeric calculation - use
§labelwhen you want one rule to depend on another rule’s pass/fail result - use
@labelfrom the Labels page when reading a value exposed by@@(...)
Example Policy
Section titled “Example Policy”Interactive Example
Policy Rule
Test Data (JSON)