What is a Roll-Up Summary Field in Salesforce?
A Roll-Up Summary field is a declarative Salesforce field available on a master object in a master-detail relationship. It calculates values from related child records and displays aggregate results on the parent (master) record. Common aggregate operations include COUNT, SUM, MIN, and MAX. Roll-up Summary fields are essential for reporting, automation, and data visibility.
Limitations & When to Use
Built-in Roll-Up Summary fields require a Master-Detail relationship between parent and child. They don’t work with Lookup relationships and have some governor limits and behavior nuances (e.g., they don’t trigger workflow rules on child changes directly). Use native Roll-Up Summary fields where possible for simplicity and performance.
Types of Roll-Up Summaries
- COUNT — number of child records that meet a filter
- SUM — sum of a numeric field across children
- MIN — smallest value of a field across children
- MAX — largest value of a field across children
How Many Ways to Create a Roll-Up Summary (Overview)
There are multiple approaches to create roll-up calculations in Salesforce depending on relationship type and complexity. Key ways include:
- Native Roll-Up Summary (Declarative) — Built-in field for master-detail relationships (COUNT, SUM, MIN, MAX).
- Flow (Record-Triggered or Scheduled) — Use Flows with Get Records + Aggregate/Loop to compute values; works with Lookup relationships and offers no-code flexibility.
- Process Builder + Flow — Trigger a Flow from Process Builder on complex criteria (though Process Builder is deprecated in favor of Flow).
- Apex Trigger — Custom triggers and AggregateResult queries for complex logic, large-volume processing, or when native and Flow solutions are insufficient.
- AppExchange Tools — Use managed packages such as DLRS (Declarative Lookup Rollup Summaries) or commercial apps like Rollup Helper to create roll-ups declaratively on lookup relationships.
- Combination Approaches — E.g., use Flow for real-time updates and scheduled Apex for recalculation of historical data.
When to Choose Each Method (Guidelines)
- Native Roll-Up Summary: Best when you have a master-detail relationship and simple aggregates. Fast and low-maintenance.
- Flow: Use when you need declarative roll-ups on Lookup relationships or when you want readable, maintainable automation without code.
- Apex Trigger: Choose when you need performance at scale, complex filtering, cross-object calculations, or bulk-safe behavior beyond Flow limits.
- AppExchange (DLRS/Rollup Helper): Use when you need quick declarative rollups on Lookup relationships and want features like scheduled recalculation, relationship modes, and complex filters without coding.
Sample Approaches
Native Roll-Up Summary (UI)
Create via: Setup > Object Manager > Parent Object > Fields & Relationships > New > Roll-Up Summary.
Flow (Record-Triggered) — High-Level Steps
- Create a Record-Triggered Flow on the Child object (after-save).
- Use Get Records (or Fast Lookup) to find related child records and use the built-in Collection functions or an Aggregate element to compute SUM/COUNT.
- Update the parent record with the computed value.
Apex Trigger + AggregateQuery Example
Use Apex when you need full control. Example aggregate query:
AggregateResult[] agg = [SELECT Parent__c, SUM(Amount__c) total FROM Child__c WHERE Parent__c IN :parentIds GROUP BY Parent__c];
Then map results and update parent records in bulk.
Best Practices
- Prefer native Roll-Up Summary fields when relationship type allows.
- Ensure bulk-safe patterns for Apex and Flows (avoid SOQL per-record).
- Use scheduled recalculation for historical fixes (DLRS or scheduled Apex) when data drift occurs.
- Monitor limits — Flow elements, CPU time, and SOQL limits can impact large datasets.
- Document the roll-up logic clearly for maintainability and audits.
Conclusion
There are several ways to create roll-up summary calculations in Salesforce: native Roll-Up Summary fields for master-detail relationships, Flows for declarative control (including Lookup relationships), Apex for complex or high-volume scenarios, and AppExchange tools like DLRS for powerful no-code rollups on lookup relationships. Choose the method that balances maintainability, performance, and the relationship model of your objects.








Leave a Reply