Problem: Within Salesforce, it is not possible to do hierarchy rollups without Apex coding. Standard Roll-summary fields will not support these types of roll-ups.
Solution: This is one of Rollup Helper's most popular use cases. You can rollup information from one child record to another parent record and up to the grand-parent. Rollup Helper can even help you in cases where you want to roll-up information for parent and child records that are on the same object, such as is the case with child accounts to parent accounts or child campaigns to parent campaigns. It is possible to have a rollup which will show a Grand Total Result from all Accounts in an Account Hierarchy.
In order to do this you will need to create 2 rollups, and a formula field to give you your Grand Total Result. Below we will count the number of Contacts as an example. This can also be done for other rollup types as well with slight modifications where necessary.
The first rollup will be a standard Count rollup.
Make sure you have a field to rollup to on Account. It should be named something similar to: Number of Contacts Under Account
This rollup will count the number of child records directly related to that specific Account Record.
Step 1: Select Account as Target object
Step 2: Select Newly created field as Target Field (Number of Contacts Under Account)
- Select Object you are rolling up (Contact)
- Select the appropriate Relationship field (AccountId)
- Select Count as the rollup type (in this example we will not use a filter)
- Save and run this setting
The second rollup necessary for this use case is going to be used in order to Sum the results of the first rollup, and store that calculation on the Parent Account.
The recommended name for the target field of this rollup is: Number of Contacts from Child Accounts
Step 1: Select Account as Target Object
Step 2: Select Newly created field as Target Field (Number of Contacts from Child Accounts)
- Select Account as the Source Object
- Select Parentid as the Relationship Field
- Select Sum As the rollup Type
- Select Target Field of first rollup as Source Field(Number of Contacts Under Account)
- Save and Run this setting after the first setting has completed calculating
Now you will have 2 separate rollup target fields - one contains the number of contacts under the account, the other contains the sum of contacts under all child accounts. However, neither of these are the grand total number of all contacts under all accounts in the hierarchy.
In order to get this result you will need to create a simple formula field. It can be called Grand Total Number of Contacts In Account Hierarchy.
The formula field will return a numeric result, it will look something similar to:
Number_of_Contacts_Under_Account__c + Number_of_Contacts_from_Child_Accounts__c
You can put this field on the page layout of your Ultimate Parent Account and hide the other 2 rollup results.