Roll-Up Summary Calculations
Learning Content
Last updated: July 21, 2026
Roll-Up Summary Calculations
A Roll-Up Summary Calculation is an automatic Salesforce process that recalculates summary values on a master record whenever related detail records are created, updated, deleted, or undeleted in a Master-Detail relationship.
Salesforce performs these calculations as part of the transaction before the final commit, ensuring that parent records always reflect the latest information from their related child records.
💡 LearnFrenzy Insight
Imagine a teacher's grade book.
Whenever a student's marks change, the teacher automatically recalculates the class average, highest score, and total marks.
Similarly, Salesforce recalculates Roll-Up Summary fields whenever detail records change, keeping the master record synchronized without requiring custom Apex code.
Where Do Roll-Up Summary Calculations Execute?
Database Save
│
▼
After Trigger
│
▼
Workflow / Flow
│
▼
⭐ Roll-Up Summary Calculation
│
▼
Parent Record Updated
│
▼
Parent Automation May Execute
│
▼
Commit Transaction
After child record automation completes, Salesforce recalculates any affected Roll-Up Summary fields on the parent record. If the recalculated values change the parent record, Salesforce may execute automation on the parent object as part of the same transaction.
What Can Roll-Up Summary Fields Calculate?
| Calculation Type | Description |
|---|---|
| COUNT | Counts related detail records. |
| SUM | Adds numeric values from child records. |
| MIN | Returns the smallest value. |
| MAX | Returns the largest value. |
Common Business Use Cases
| Business Requirement | Roll-Up Summary Solution |
|---|---|
| Total Opportunity Amount | SUM of child Opportunity values. |
| Number of Active Contracts | COUNT related Contract records. |
| Highest Invoice Amount | MAX invoice value. |
| Earliest Project Date | MIN project start date. |
| Total Products Ordered | SUM quantity from Order Line Items. |
Real Business Scenario
🏢 Business Example
An Account has multiple Opportunities connected through a Master-Detail relationship.
When a new Opportunity is created:
- The Opportunity Amount is included in the Account's Total Revenue Roll-Up Summary field.
- The parent Account is automatically updated.
- If the Account contains an After Trigger or Record-Triggered Flow, Salesforce may execute that automation as part of the same transaction.
Roll-Up Summary vs Formula Field
| Feature | Roll-Up Summary | Formula Field |
|---|---|---|
| Calculates Child Records | ✔ Yes | ❌ No |
| Stores Value | ✔ Yes | ❌ Calculated at runtime |
| Master-Detail Required | ✔ Yes | ❌ No |
| Triggers Parent Updates | ✔ Possible | ❌ No |
| Calculation Types | COUNT, SUM, MIN, MAX | Formula Expressions |
What Happens After Recalculation?
| Situation | Salesforce Behavior |
|---|---|
| Roll-Up Value Changes | Parent record is updated. |
| Parent Has Triggers | Parent triggers may execute. |
| Parent Has Record-Triggered Flows | Parent flows may execute. |
| Parent Update Fails | Entire transaction is rolled back. |
🔍 Behind the Scenes: What Happens Internally?
Child Record Saved
│
▼
Automation Completes
│
▼
Roll-Up Summary Recalculated
│
▼
Parent Value Changed?
Yes │ No
│
▼
Parent Record Updated
│
▼
Parent Trigger / Flow May Execute
│
▼
Continue Transaction
│
▼
Commit Happens Later
Although Roll-Up Summary calculations are automatic, they are still part of the current transaction. If automation on the parent record throws an unhandled exception, Salesforce rolls back both the parent and child changes to preserve data consistency.
Why Roll-Up Summary Calculations Matter
| Benefit | Explanation |
|---|---|
| Automatic Aggregation | No Apex required for standard totals and counts. |
| Accurate Parent Data | Parent records always reflect the latest child information. |
| Integrated Automation | Supports parent triggers and Flows when values change. |
| Data Integrity | Maintains consistency within the transaction. |
✅ Best Practice
Use Roll-Up Summary fields whenever your requirement involves aggregating data across a Master-Detail relationship. Before writing Apex or Flow for totals, counts, minimums, or maximums, check whether a Roll-Up Summary field satisfies the requirement.
⚠️ Common Mistake
Forgetting that updating a child record can indirectly update the parent through a Roll-Up Summary field. This may trigger additional automation on the parent object and affect the overall transaction.
🎯 Interview Tip
Question: Can updating a child record cause automation to execute on the parent record?
Answer: Yes. If the child record changes a Roll-Up Summary value on the parent, Salesforce updates the parent record. That update can execute parent Record-Triggered Flows, Validation Rules, and Apex Triggers as part of the same transaction.
- ✔ Automatically recalculates parent summary fields.
- ✔ Works only with Master-Detail relationships.
- ✔ Supports COUNT, SUM, MIN, and MAX.
- ✔ Executes before the final transaction commit.
- ✔ May update the parent record and trigger additional automation.
- ✔ Parent update failures roll back the complete transaction.
➡ Next Lesson
In the next lesson, you'll learn about the Commit Transaction stage, where Salesforce permanently saves all successful changes, explains why rollback is no longer possible after commit, and introduces post-commit operations.
Practice What You've Learned
Test your understanding with these practice exercises