Build Expression Sets for Rating
Learning Objectives
After completing this unit, you’ll be able to:
- Create an expression set.
- Explain the steps to add variable and constant resources.
- Create steps for lookup tables, calculations, and aggregations.
- Prepare an expression set version for use.
Create an Expression Set
With his decision matrices defined and enabled, Solution Architect Justus is ready to dive into the center of a rating procedure’s pricing logic: expression sets. These sets define the formulas and calculations that turn product information and matrix data into final premiums.
Justus begins by creating a new expression set named greatPricing. Salesforce automatically creates its initial version named greatPricing V1. He can easily add more versions as pricing models evolve over time.
As you build your expression set, refer to the rating steps you defined during the rating preparation phase in unit 2. These steps include your ordered list of matrix lookups and formulas, along with the sources of your input values. Finally, when using multiple expression sets, remember the designated steps for each.
Add Resources
Create your calculation steps within the Expression Set Builder. Access it by opening your desired version and then click Open in Expression Set Builder.
-
Canvas (1): Drag and drop your elements here.
-
Panels (2):
- Elements: Use to list available elements, also known as steps, to add to the canvas.
- Resource Manager: Use to add and edit resources, which are variables and constants, used in elements.
- Expression Set Properties: Use to view version details such as its start date, end date, and rank.
- Element Details: Use to view properties of the selected step, such as a checkbox to output step results.
- Elements: Use to list available elements, also known as steps, to add to the canvas.
Remember to save your work when you’re finished.
Create Lookup Tables, Calculations, and Aggregations
Before adding formulas, you add resources. Any input variable, output variable, or named constant for a formula must first exist as a resource. Use the resource manager to view, add, edit, and delete resources.
To add a new resource, click Add Resource and fill in a few fields. For more information about key resource fields, check out Expression Set Resources.
Before manually creating a variable, check if it’s already present in matrices. When you reference a decision matrix, its variables are added automatically. Matrix output variables in the expression set are prefixed by matrixName__variableName
.
Expression Set Steps
An expression set consists of steps, also called elements. Although there are several types of steps, these are the common ones.
-
Lookup Table: Use this step to reference a lookup table, such as a decision matrix, for rating table data.
-
Calculation: Use this step to add a formula.
-
Aggregate: Use this step for an aggregate function such as SUM, AVG, MAX, or MIN.
Drag a step from the elements panels to the canvas to add it. Then, configure it. The step order matters. If output from one step is input for another, put the output step first. There are handy icons to cut, copy, paste, and delete a step.
Lookup Table Element
To reference a decision matrix, add a lookup table element. To configure this element, there's only one piece of information to provide—the name of the matrix. Start typing its name in Lookup Table Details, and a list of enabled matrices appear for selection.
Here’s a lookup table for driverSafe matrix that looks up if the driver qualifies as safe.
After you select the matrix, its input variables and output variables are listed on the element and in the resource manager. Names of output variables are automatically prefixed with matrixName__
to ensure unique output names. The resource manager shows the prefixed names which you can use in calculations.
Calculation Element
For a calculation element, enter the input calculation in the Formula field, and enter the variable for storing the result in the Output Variable field. As you type, any matching variables, constants, functions, and operators appear for selection.
For more information, check out Operators and Functions in Expression Sets.
Aggregate Element
The aggregate element is for aggregate functions such as SUM that run across the results of multiple input sets. First, you complete the steps for each input set, and then run the aggregations using those results.
Consider this table that has inputs in the first column, with each input set in its own row. With a matrix lookup, the expression set gets individual rates, which are in the second column. The desired output is the aggregated sum of individual rates, which is in the third column.
Inputs |
Matrix Lookup |
Aggregation |
---|---|---|
Male, 52, Smoker, SG-500 |
$2075 |
$4300 |
Female, 55, NonSmoker, SG-25 |
$1300 |
|
Male, 26, NonSmoker, SG-500 |
$925 |
Configuration of an aggregate element is similar to that of a calculation element, but there are some differences.
- The formula must include an aggregation function such as SUM, AVG, MAX, or MIN.
- Aggregation must appear at the end of the expression set.
- When you add an aggregate group element, it automatically includes an aggregate element.
- There can be only one aggregate group. If you need more than one aggregate element, add it to that group.
You do all the aggregation steps last. Therefore, if the output of an aggregate step is needed as input for another step, that step goes in a second expression set.
Element Details
Each element you add has details, also known as properties. The Element Details panel shows properties for a selected element.
-
Name: Give a custom name to distinguish steps of the same type.
-
Description: Add information beyond the custom name.
-
Include in Output: This one's critical. Select this checkbox to include the output of a step in the calculation output or aggregation output. This provides output for use in aggregation steps and for rating results.
In expression set output, there are calculation results and aggregation results. The calculation results contain the output of the steps before aggregation that are marked to Include in Output. The calculation results are the input for aggregation.
Result Simulation
You’ve built the steps. Now, it’s time to test.
Before running the simulation, provide values for the Effective Date and Input Resources fields.
Click Simulate to run the simulation and view the results. In the canvas area, you get result details for each step. Confirm that every step executes as expected. If there are problems, troubleshoot them using the step details.
When testing, try simulating it a few times with different inputs and confirm that results adjust accordingly. If all is working properly, activate it.
Nice work. Now you know how to prepare an expression set using lookup, calculation, and aggregation steps. After simulation and activation, you know these expressions are ready to calculate accurate premiums. For more complex logic requiring multiple expression sets, you need an Integration Procedure. In the next unit, discover how these procedures orchestrate calculations across sets and combine all the pieces of the rating procedure.