Skip to content

Per-policy calculations

The loopTable function can be used to perform efficient per-policy calculations.

This tutorial shows the basic pattern for running one projection node once per policy row.

1. Create a policy table

Add a table to the model workbook called t_Policies. For example:

PolicyID SumAssured PremiumRate
P001 100000 0.012
P002 250000 0.010
P003 150000 0.014

Each row represents one policy to calculate.

2. Read policy values with loopTable

Add variables that read from the current policy row:

VariableSetName VarName Formula
PolicyRun PolicyID loopTable("t_Policies", "PolicyID")
PolicyRun SumAssured loopTable("t_Policies", "SumAssured")
PolicyRun PremiumRate loopTable("t_Policies", "PremiumRate")
PolicyRun Premium SumAssured * PremiumRate

Because the first three formulas all reference t_Policies, Autory creates one loop over that table and reuses it for each column.

3. Configure aggregation

In the Variables table, choose how each variable should be aggregated across policies:

VarName ResolveAggregation
PolicyID Ignore
SumAssured Sum
PremiumRate Mean
Premium Sum

Use Ignore for identifiers that are only meaningful in the detailed per-policy results. Use Sum, Mean, Max, Min, First, or Last for values that should appear in the aggregated results.

4. Run the model

When the projection node uses PolicyRun, Autory calculates one iteration for each row in t_Policies. The detailed output contains the policy-level values, while the aggregated output contains totals and other configured aggregations for the projection node.

For the sample table above, the detailed results include:

Iteration PolicyID SumAssured PremiumRate Premium
1 P001 100000 0.012 1200
2 P002 250000 0.010 2500
3 P003 150000 0.014 2100

The aggregated Premium result is 5800.