Roll-Up Summary Field
A roll-up summary field is a custom field on a master record that automatically aggregates values from its child detail records through a master-detail relationship.
Definition
A roll-up summary field is a custom field on a master record that automatically aggregates values from its child detail records through a master-detail relationship. It supports four aggregate operations: COUNT, SUM, MIN, and MAX. The field recalculates whenever a related detail record is created, updated, deleted, or undeleted, so the master always shows the current totals without any automation or scheduled job to refresh it.
Roll-up summaries only work on master-detail relationships, never on lookup. That single constraint shapes most data-model decisions in Salesforce. When a team needs a real-time total on the parent (count of related opportunities per Account, sum of contract values per Customer, max close date across a project's tasks), they either model the relationship as master-detail or fall back to a workaround: scheduled Apex, the Declarative Lookup Rollup Summaries package, or a Flow that recalculates on demand.
How roll-up summary fields keep parent records current
The master-detail requirement and why it exists
Roll-up summary fields are physically possible only because master-detail relationships guarantee that every detail record has exactly one parent and that the parent reference cannot be null. The platform uses this guarantee to maintain an internal aggregate that updates in place when a detail record changes. Lookup relationships allow null and reparenting, so the platform cannot keep a stable aggregate without scanning the full child set on every change. That is why lookup-based roll-ups require workarounds and never appear as a native field type.
The four operations and their use cases
COUNT returns the number of detail records, with optional filter criteria. SUM adds a numeric or currency field from the detail records, again with optional filters. MIN and MAX find the smallest or largest value, useful for dates (earliest close date, latest activity date) and for numeric thresholds. Each operation is recalculated on the master in real time. Picklist values, multi-select picklists, and text fields are not directly aggregatable; convert to a number or use a flag-style approach if you need that pattern.
Filter criteria narrow the aggregate
Each roll-up can carry a filter that restricts which detail records contribute. Count only Closed-Won opportunities. Sum only line items where Status equals Approved. The filter uses the same syntax as workflow criteria, including field comparisons and AND/OR logic. Changing the filter forces a full recalculation on every master record, which can take hours on large objects, so plan filter changes during a maintenance window.
Recalculation behavior and timing
When a detail record is created, updated, or deleted, the platform updates the master's roll-up value as part of the same transaction. The master record is locked briefly while the update happens. In bulk loads, this lock contention can produce UNABLE_TO_LOCK_ROW errors when many detail records under the same master are processed in parallel. Use Bulk API sequential mode or pre-sort the data by master ID to reduce lock conflicts.
Limits per object and per org
Each master object supports up to 25 roll-up summary fields by default, raisable to 40 through support. Each org also has a total roll-up limit per object type. Roll-ups on the same master that share an aggregate operation and reference the same source field cannot easily be deduplicated, so plan field naming and reuse before approaching the limit. When you run out of slots, common workarounds include consolidating multiple counts into one field with conditional logic in the filter.
Performance under heavy detail volume
Roll-ups are fast for most workloads but cost real CPU at scale. A master with more than 10,000 detail records can trigger the CPU governor during bulk operations, especially with multiple roll-ups on the same parent. The Skinny Table pattern does not help here because roll-ups live on the master row. For very large detail volumes, consider a stored field updated by Batch Apex on a schedule, accepting a small staleness window in exchange for eliminating the recalc cost during loads.
Common alternatives when master-detail is not an option
When the relationship has to stay lookup (because the child needs its own owner, or because reparenting is required), teams use three workarounds. The Declarative Lookup Rollup Summaries package from Andy Fawcett is the most popular: install it from AppExchange, configure roll-ups through a wizard, and it generates the supporting Apex automatically. Flow-based roll-ups work for small detail volumes. Scheduled Batch Apex works for huge detail volumes where overnight freshness is acceptable. Each trades real-time accuracy for relationship flexibility.
How to create a Roll-Up Summary Field
Roll-up summary fields are quick to set up but easy to misconfigure. The relationship must be master-detail. The aggregate type and filter shape the recalculation cost. Setting the filter incorrectly forces a full back-fill across every existing master record, which can take hours on large data sets. Build in a sandbox and validate the recalculation behavior before promoting to production.
- Confirm the relationship is master-detail
Open the detail (child) object and check the relationship field. If it is lookup, the master object will not show the roll-up summary field type in the picker. Convert lookup to master-detail only if every child record has a populated parent and the conversion is acceptable for sharing.
- Create the field on the master object
Object Manager, master object, Fields and Relationships, New, Roll-Up Summary. The wizard appears only if at least one master-detail relationship exists. Give the field a name that includes the operation, like Total_Opportunity_Amount__c or Count_Open_Cases__c, so it is self-documenting.
- Pick the detail object and aggregate operation
Choose the detail object from the dropdown (multiple master-detail relationships show as separate options). Pick the operation: COUNT (no source field needed), SUM, MIN, or MAX (each needs a source numeric or date field). Save the operation choice deliberately because changing it later forces a full recalculation.
- Add filter criteria if needed
Click Add Filter to narrow which detail records contribute. The filter uses workflow-style syntax with field comparisons, AND/OR logic, and grouping. Keep the filter simple because complex filters slow recalculation on every detail change.
- Set field-level security and add to layouts
Configure FLS for the profiles that need to see the aggregate. Add the field to the master page layout in a section that signals it is a derived value. Many teams group roll-ups in a "Summary" section so users do not try to edit them.
- Trigger the initial recalculation if data exists
When the field is created on an object with existing detail records, the platform runs a back-fill batch automatically. Monitor the recalculation through Setup, Background Jobs. For large objects, schedule the field creation during off-peak hours because the back-fill consumes API and CPU capacity.
- Test recalculation by editing detail records
Create a new detail record under a master, edit an existing detail's filter-relevant field, and delete a detail record. Confirm the master's roll-up value updates in each case. This proves the formula, filter, and lock behavior all work as intended.
The child object whose records are aggregated. Must be connected to the master through a master-detail relationship.
COUNT, SUM, MIN, or MAX. Changing later forces a full recalculation across every master record.
The numeric or date field on the detail object whose values are aggregated. COUNT does not need a source field.
- Roll-up summaries only work on master-detail relationships. If the relationship is lookup, the field type does not appear. Convert to master-detail or use a third-party rollup tool like DLRS.
- Filter changes on a roll-up summary force a back-fill across every master record. On large objects this can lock related batch jobs for hours, so schedule filter changes during a maintenance window.
- Bulk DML on detail records under the same master can produce UNABLE_TO_LOCK_ROW errors because the master is locked during recalculation. Sort data by master ID or use Bulk API sequential mode to reduce contention.
- Each master object supports up to 25 roll-ups by default, raisable to 40 through Salesforce support. Consolidate filtered roll-ups into one field with conditional source logic if you run out of slots.
- Roll-ups on parents with more than 10,000 detail records can trigger CPU governor limits during bulk loads. Consider Batch Apex with a scheduled refresh as the alternative for very large detail volumes.
Trust & references
Cross-checked against the following references.
- Roll-Up Summary Field OverviewSalesforce Help
- Define a Roll-Up Summary FieldSalesforce Help
- Roll-Up Summary Field ConsiderationsSalesforce Help
Straight from the source - Salesforce's reference material on Roll-Up Summary Field.
- Define a Roll-Up Summary FieldSalesforce Help
- Roll-Up Summary Field ConsiderationsSalesforce Help
- Roll-Up Summary ExamplesSalesforce Help
Hands-on resources to go deeper on Roll-Up Summary Field.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. Which Salesforce Cloud is Roll-Up Summary Field most closely associated with?
Q2. What best describes the purpose of Roll-Up Summary Field in Salesforce?
Q3. Who would typically configure or interact with Roll-Up Summary Field?
Discussion
Loading discussion…