IMPORTANT
After the October 2018 release, Admins cannot create new Custom Rules. Gainsight recommends creating Bionic Rules as they are more powerful than Custom Rules, and they help Admins reduce the number of overall rules that you need to configure and manage.

For assistance with Bionic Rules, check out the following resources:

 

This tutorial demonstrates you on how you can use Custom Rules to perform Aggregations.  There are two methods to aggregate data in Custom Rules. Both the methods are explained in this tutorial.

Notes

  • 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.

Aggregation Methods

In a Custom Rule, you can perform aggregation by two methods. 

  • Aggregating using the Show section
  • Aggregating using the Add Calculated Field

Aggregation using the Show section

In this method Aggregation is performed on a field when it is added in the Show section. In this method, you cannot modify the time period for aggregation. 

Create Rule

  1. Navigate to Administration > Rules Engine.
  2. Click + RULE
  3. Select Custom as the Rule Type.
  4. Create the Rule For an Account.
  5. Enter a name in the Rule Name field.
  6. (Optional) Add a description, in the Description field.
  7. Click Next.

Setup Rule Show Section

  1. Select Native Data as the source.
  2. Select Usage Data as the source Object.
  3. Add the following fields to the Show section:
  • Account:: Id
  • Usage Data::User Activity
  • Usage Data::Created Date

Setting up show fields.png

Perform Aggregation

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

Aggregating on User Activity.png

Aggregation using Calculated Fields

In this section, the aggregation is performed using the Add Calculated Field option. In this method of aggregation, you can choose specific time period for which the aggregation must be done. In this example Average is aggregated for the past 90 days.

  1. Click Add Calculated Field. 

using the calculated field button.png

  1. In the Add Calculated Field window:
  • Enter a name in the Field name field.
  • Select Aggregation (over time) as the Type of calculation.
  • Select AVG as the aggregation type.
  • Select User Activity as the metric.
  • Enter 90 and select Days.
  • Select the Adjust for missing data check box. This ensures that if data is missing for any given date, the average calculation is adjusted to consider only the available data.
  • Click OK.

Aggregation from Calculated field.png