Skip to main content
Gainsight Inc.

Tutorial - Custom Grouping, Time Series, and Pivoting using Bionic Rules

In this tutorial, we will use Bionic Rules and demonstrate its capabilities with a scenario. This tutorial also demonstrates that by creating a single Bionic Rule, you can achieve goals which were only possible earlier using multiple rules.    

Following are the goals we intend to achieve using a single bionic rule: 

  1. Fetch all the cases from the Case object (Fetch Task). 
  2. Pivot: After the cases are gathered in a output dataset, pivot it on Priority field (Pivot Task).
  3. Time Series Filter: Group the cases that are created in 14 day period (Transformation Task). 
  4. Custom Group: Finally, merge the pivoted dataset (Priority) and the output of cases created in 14-days (Merge Task). 
  5. Load to MDA

Fetch all cases from the Case object

  1. Navigate to Administration > Rules Engine.
  2. Click Create Rule.
  3. Select the Rule Type as Bionic, and enter the Rule Name and Description (optional).
  4. Click NEXT.

Bionic Rule Name.png

  1. In the Setup Rule screen, click DATASET TASK

Click DATASET.png

  1. Enter the Task Name. The Output Dataset Name is populated automatically.
  2. Select Salesforce as the data source and Case as the source object.
  3. Drag and drop the following fields in the Show section:
  • Account ID: This is a mandatory field for building a rule.
  • Account ID Name: To get the account names related to all the cases.
  • ID: This field is used to get the identification of the case.
  • Priority: To get the priority of all the cases. This field is important for this tutorial.
  • Created Date: This field is useful to filter the cases that fall in a 14-day period.
  • Case Number: This field is used to get the number of the case.
  1. Click SAVE.

Fetch all the Cases from Case Object.png

Pivot the Dataset on Priority

Using the output dataset of the previous task (GetAllCases), pivot the dataset based on Priority. 

  1. In the Setup Rule screen, click + TASK and select Pivot. 

Click PIVOT.png

  1. Select the output dataset name from the previous task as the source object (In this example, Get All Cases). 
  2. Select Account ID, ID, and Created Date as Show fields. 

Pivot the Dataset on Priority.png

  1. Drag and drop Priority from the fields section in the Pivot On section. The Configure Conditions dialog appears. 

Priority Conditions.png

  1. Add conditions in the dialog. In this tutorial, we are counting the number of high priority cases. Configuring a condition is mandatory to proceed. 
  1. Drag and drop Account ID and Created Date fields in the Group By section. 
  2. Click SAVE.

Pivot the Dataset on Priority 2.png

Filter the cases in the last 14-days 

In this step, we’ll group the cases that are created in the last 14-days. 

  1. In the Setup Rule screen, click + TASK and select Transformation.


  1. Select the source as Get All Cases
  2. Select Account ID, ID, and Case Number as Show fields. 
  3. Group by Account ID and Case Number.
  4. Add the following filter criteria:  
    1. Created Date <= 14. From the rule date, subtract 14 days. 
    2. From the rule run date, subtract 15 days so that the rules run on the 14th and 15th day are also included. 
  5. In the Advanced Logic section, type A AND B. This is to ensure values from both the filters are included. 
  6. Click SAVE

Filter All the Cases from the Case Object 2.png

Merge outputs of Pivoted task and 14-day period

The output datasets of Pivoted task (Pivot the Dataset on Priority) and 14-day period (Filter the Cases in a 14 day Period) are merged using a Merge task. 

  1. In the Setup Rule screen, click + TASK and select Merge


  1. In the Criteria section, select the output datasets. Pivot the Dataset on Priority and Filter the Cases in a 14 day Period
  2. Select the join type as Retain all records from left dataset.
  3. In the Show Fields section, select the fields that you want to include in the final dataset. 
  4. Click SAVE.

Merge Outputs.png

Load to MDA

Once you have the final dataset from the previous step, you can load the dataset to MDA. 

  1. In the Setup Action screen, click + ACTION and select Merge for Cases.


  1. Select Load to MDA Subject Area
  2. Select an object from Object Name list. Once you select the object name, you can see the field mappings. 
  3. Select Upsert from the Operation list. 
  4. Map the fields from output dataset with the MDA object’s fields. 
  5. Click SAVE. Run the rule to see the output. 

Load to MDA.png