People Attribute Details: Calculation Rules

Overview

A Calculated Attribute is a special type of People Attribute whose value is dynamically derived instead of being specified. The Calculated Attribute value holds the result of the calculation as it was last computed.

To create a Calculated Attribute, check calculated when defining the Attribute properties. The Calculation Rules tab and Variables tab are displayed within the People Attribute Details screen.  

At a minimum, a Calculated Attributed is defined by the following:

The platform supports two different methods of refreshing the values in a Calculated Attributes. These methods (called "computation modes") are On-demand and Scheduled.  

On-demand

On-demand computation happens when some event or caller needs to display the value in the Calculated Attribute for an individual. This caller could be, for example, a mobile app, a website, an API call, or a user within the platform's interface.

When this call occurs, the platform checks the Time-to-Live value for the Calculated Attribute for the referenced Member. If the current time is beyond the TTL range, the platform will recalculate the value in the Calculated Attribute. Conversely, if the current time is still within the TTL range, the platform will simply show the existing "cached" value.

Scheduled

Scheduled computation occurs based on a Scheduled Job. A Scheduled Job executes at a designated frequency, and it will recalculate the values in the Calculated Attribute for every customer record in the database.

Features

The features and options available from the Calculation Rules tab are described below.

  Define Conditions -- Simple

Click hereClick here

Create a Rule 

Rules allow you to define the conditions for which Person records will have the Calculated Attribute derived. To create a Rule:

  1. Select simple.

  2.  Click add rule.

  3. The new Rule defaults to a condition of "Always True," meaning the Calculated Attribute will be derived for every Person record. To add a condition, click the Edit icon next to "Always True."

  4. Click the Add icon, then select Add Rule. The platform adds a new blank row for defining the Rule Condition. 

  5. From the first drop-down menu, select the desired element.

  6. Select a mathematical operator. The available operators will vary based on the element selected in the previous step. 

  7. Enter or select a value. 

  8. Some elements allow you to define additional criteria, such as a date range, or a channel type, for example. Select or enter the additional criteria. 

  9. Repeat the above steps as needed to define more Rule Conditions. If you need to delete a Rule Condition, click the Delete icon to it. 

  10. Once you define more than one Rule Condition, select the logical operator. From the "Include customers that meet" drop-down menu, select either: 

  • All of the following: The conditions are processed with a logical 'AND' operator such that all conditions must be true for an individual to be included. 

  • Some of the following: The conditions are processed with a logical 'OR' operator such that at least one of the conditions must be true for an individual to be included. 

  1. Optionally, to see the Groovy expression generated by your Rule Condition, click show expression

  2. Optionally repeat the above steps as necessary to create more Rules. You can change the sequence in which the Rules are arranged by clicking-and-dragging on the "handle" area to the left of the Rule, and dropping it into its desired position. Optionally, to delete the entire Rule, click delete.  

  3. Click save.  

Create Rule Groups

Optionally, you can organize Rule Conditions into a Rule Group. The Rule Group has its own AND / OR operator which allows you to define more complex, sophisticated Rules. To create a Rule Group:

  1. Click the Add icon, then select Add Rule Group. The platform adds a new Group with a blank row for defining the logical condition within the Group.

  2. Follow the steps as described above for creating Rule Conditions within the Group. 

  3. Select the logical operator to use for the Conditions within the Rule Group. 

  4. Repeat the above steps as needed to define more Rule Conditions within the Group. 

  5. Repeat the above steps as needed to define more Rule Groups. You can use the Add Rule Group option at either the parent level, or within an existing Rule Group, thereby allowing you create a "nested" Group. The platform indents Rule Groups to help you visually identify the hierarchy of Groups.

  6. If you need to delete a Rule Group (and all Rules within it), click the Delete icon next to it. 

  7. Click save

Define Result

The "Result" section is used to define the value that gets assigned to the Person records selected by a Rule. The platform supports several different methods of deriving the Result.

Define Result: SimpleDefine Result: Simple

Define Result: ExpressionDefine Result: Expression

Define Result: BinningDefine Result: Binning

Define Result: Activity AggregateDefine Result: Activity Aggregate


 

  Define Conditions -- Advanced

Click hereClick here

To define a Calculated Attribute using a Groovy expression:

  1. Select advanced.

  2. In the code editor, enter your Groovy expression.

  3. Click save

 

Back to People Attribute Details