Tutorial Overview

Subject: This tutorial demonstrates how to use the Rules Engine to create Aggregations.
Scenario: Use this in the event that you need to measure a particular statistic such as the average of activity
Complexity: Easy/Medium
Description: An overview of the Aggregation system. In this tutorial two different ways to create an aggregation will be covered.
Challenges: There are two different ways that an aggregation can be created, this tutorial will show both but adding both is not necessary.
Approach:
  1. Creating a Rule
  2. First Creation - Using Fields
  3. Second Creation - Using Calculated Fields
  4. Finishing the Rule

Notes and Tips

General:

  • This tutorial is presented for educational purposes only.
  • Always test your rules before running them in a production environment.
  • Understand your Salesforce environment before performing any operations which may affect your data.

Step 1 - Creating the Rule

  1. Click Administration > Rules Engine > click +Rule, or edit an existing one.

Rule Creation

  1. Select Custom rule
  2. Select Account
  3. Enter a descriptive name for the rule
  4. (Optional) Add a description
  5. Click Next

Step 2 - Select Show Fields

This explains how to create aggregations using the Show and Filters areas of the Setup Rule page.

Source Data & Show Fields

  1. Select Native Data and the Usage Data object.
  2. Add the following fields to Show:
  • Account:: Id
  • Usage Data::User Activity

Select Aggregation

  1. Click the drop down arrow on User Activity and select the aggregation desired (this example uses AVG).

Create Filters

  1. Create the following filters:
  • Usage Data::Date equals Subtract N Days from Rule Date 30
  • Usage Data::Date equals Rule Date

Select Next at the bottom of the page to save the rule, this is how the rule is created using the Fields.

Step 3 - Second Creation - Calculated Fields

This section shows how to create an Aggregation using the calculated field.

The Show Field

  1. Select Native Data
  2. Select Usage Data from the drop down menu
  3. Drag in Account:Id into the Show field
  4. Do NOT drag anything into the Filters section
  5. Click Add Calculated Field

The Calculated Field - Comparison

This field will calculate the aggregation when comparing two different parts of data. In this tutorial the AVG will be calculated.

  1. Name the field
  2. Select Comparison or Aggregation (can only choose one)
  3. Set the first portion of the comparison (More description in next section)
  4. Set the second portion of the comparison
  5. This area is changed on a different page, it will demonstrate where later
  6. Click Ok

The Calculated Field - Aggregation

  1. Name the Field
  2. Can be changed back to Comparison (Can only choose one)
  3. Select how the type of calculation
  4. Select what is going to be compared
  5. Select the timeframe for the rule to run
  6. Type in how long ago the rule will check
  7. Select the timeline for the rule to look at
  8. Select this check box if the rule should self check for missing data. (I.e. Data only comes in every 5 days but its set to 7 days, it will drop those two days of no data.)
  9. This is changed on a different page that will be shown in the next section
  10. Click "Ok"

Changing the "Time Identifier: Created Date" box

  1. After clicking "Ok" it goes back to the rule creation page
  2. Scroll down and find the Time Identifier
  3. Using the drop down select a different Time Identifier.
  4. Click Next to save the rule

Time Identifier Changed

Back under the calculated field the Time Identifier will now be whatever was selected on the previous page.

Step 4 - Finishing the Rule

The rule is completed after clicking Next on either configuration as there is no action to be set up, as long as it will be run manually. If the rule should be run on a schedule then this final step will need to be completed.

Scheduling the Rule

  1. Select Schedule at the top
  2. Select how frequent the rule should be ran
  3. Select a start and end date if desired
  4. Choose a time in which the rule should run (best practice is to choose a non busy time to run before people look at the data)
  5. Where a failed rule will be emailed
  6. Select "Run for historical periods" if the rule should check previous points in time (I.E. Last 30 days)
  7. Click Start to have the rule start running