How do custom summary formulas and rollups enhance pipeline analytics on parent accounts?
Answer
Basics: Roll-up summary fields exist only on the master side of a master-detail relationship, supporting COUNT, SUM, MIN and MAX (no average). Opportunity to Account is a lookup, so you need another route to put Open Pipeline or Weighted Pipeline on an Account. Custom summary formulas are different: they are report-level calculations over grouped data.
How it works:
- Reports: add a custom summary formula (for example weighted amount divided by count, or PARENTGROUPVAL, PREVGROUPVAL) on a summary or matrix report; up to 10 summary formulas per report. Row-level formulas work per row.
- Flow: record-triggered flow on Opportunity that collects affected account Ids, uses Get Records or an aggregate loop, and updates the Account.
- Apex: trigger plus handler running an aggregate SOQL grouped by AccountId, then updating accounts.
- Declarative Lookup Rollup Summaries (open source DLRS) or an AppExchange option for configuration-only rollups.
Advanced / deep dive: Rollups from triggers must handle inserts, updates (including AccountId changes, so recalc both old and new account), deletes and undeletes. Hot accounts with thousands of opportunities cause row locking when many opportunities update at once; consider scheduled or queued recalculation to avoid UNABLE_TO_LOCK_ROW. Averages and win rate are derived: store sum and count, then compute with a formula field. In multi-currency orgs, convert amounts consistently. For analysis over huge volumes, use CRM Analytics, not stored rollups. Account hierarchy rollups (child accounts to parent) are a further step and are usually done by Apex or DLRS.
Code / config example:
public static void {
Map<Id, Account> upd = <Id, Account>();
(Id a : acctIds) upd.put(a, (Id = a, Open_Pipeline__c = , Weighted_Pipeline__c = ));
(AggregateResult ar : [
SELECT AccountId a, SUM(Amount) amt, SUM(ExpectedRevenue) wtd
FROM Opportunity WHERE AccountId IN :acctIds
GROUP BY AccountId]) {
upd.get((Id) ar.get());
ac.Open_Pipeline__c = (Decimal) ar.get();
ac.Weighted_Pipeline__c = (Decimal) ar.get();
}
update upd.values();
}