The "Aggregate by Hierarchy" feature allows automatic data aggregation across hierarchy levels for self-lookup relationships. When enabled, rollup calculations will dynamically consider parent-child relationships within the same object, ensuring hierarchical data is accurately rolled up.
Example: Aggregating Call Records Across Account Hierarchy
Scenario:
An organization tracks customer interactions through a Call object, which has a lookup relationship to the Account object. Each account can have multiple child accounts forming a hierarchy. The goal is to calculate the total number of call records not only for a specific account but also for its nested child accounts.
Solution using "Aggregate by Hierarchy" in PWR Rollups:
First Rollup Configuration:
Source Object: Call
Target Object: Account
Rollup Type: Count (Total Calls)
Hierarchy Rollup: Calls→ Account
Field to Rollup: Call Id
Second Rollup Configuration:
Source Object: Account
Target Object: Account(Parent Account Id)
Aggregate by Hierarchy: ✅ (Checked)
Rollup Type: SUM (All Nested Calls)
Hierarchy Rollup: Account → Account (self-lookup hierarchy)
Field to Rollup: Total Calls(previous rollup result field)
Formula for Immediate Child Calls
Create a formula field on Account:
Formula:Total Calls + All Nested Calls
Outcome:
If an account has direct call records, those will be counted.
If an account has child accounts with their own call records, those will also be included in the total.
If there are multiple levels in the hierarchy, PWR Rollups ensure that all nested calls are summed up correctly at each level.
Refer to the screenshot below for the result.