A roll-up summary field is a declarative field defined on the master object in a master-detail relationship that aggregates values from the related detail records. It supports four operations — COUNT, SUM, MIN, and MAX — and recalculates automatically whenever detail records are inserted, updated, or deleted. Roll-up summaries are only available on master-detail relationships, not on lookup relationships.
The four operations
| Operation | What it does | Field types it works on |
|---|---|---|
| COUNT | Counts the number of detail records | Any (no field selection — just counts rows) |
| SUM | Sums a numeric field across details | Number, Currency, Percent |
| MIN | Smallest value across details | Number, Currency, Percent, Date, Date/Time |
| MAX | Largest value across details | Number, Currency, Percent, Date, Date/Time |
You can also filter the rolled-up records by criteria — e.g., sum only Won opportunities, count only open cases, max only after a specific date.
Where roll-up summaries live and what powers them
A roll-up summary is a field on the master that pulls from the detail. It is read-only to users (you can never type into it) and is recomputed by the platform on every relevant detail change.
Example structure:
Invoice (master)
Number_of_Lines__c = COUNT(Invoice_Line_Item__c)
Total_Amount__c = SUM(Invoice_Line_Item__c.Line_Total__c)
Earliest_Line_Date__c = MIN(Invoice_Line_Item__c.Line_Date__c)
Largest_Line__c = MAX(Invoice_Line_Item__c.Line_Total__c)
Invoice_Line_Item (detail)
Quantity__c, Unit_Price__c
Line_Total__c = Quantity__c * Unit_Price__c ← formula
Line_Date__c
Add or change a line item, and all four roll-up fields on the Invoice update in the same transaction.
Why only master-detail supports roll-up summary
Roll-up summary recalculates by walking the relationship: from each master, find every detail child, aggregate the chosen field. For Salesforce to do this efficiently and correctly:
- The relationship must be required (every detail has a parent — no orphans to ignore).
- The relationship must be cascade-aware (the platform knows when details are added/deleted).
- The detail must not have its own independent owner/sharing that complicates aggregation timing.
Lookups don’t enforce any of those constraints — children can be orphans, can be reparented freely, can have any owner. Salesforce chose not to support roll-up summaries on lookups for these reasons.
Limits
- Up to 25 roll-up summary fields per object (this limit has shifted over releases — confirm in the current Salesforce docs for your release).
- Each roll-up summary is recalculated within the same transaction when the detail changes.
- Filter criteria on the roll-up: you can use most field types, but multi-select picklist, long text area, and a few other types are not allowed in filter conditions.
- If you change a roll-up summary definition (or recalculate manually), Salesforce queues a mass recalculation — on large datasets this runs asynchronously and may take a while.
What about lookup relationships?
You cannot create a built-in roll-up summary on a lookup. Workarounds:
- Convert the lookup to a master-detail — possible only if every existing child has a non-null lookup value, and only if the data model genuinely fits master-detail’s stricter semantics.
- Use Flow to maintain a custom number field on the parent — increment/decrement on detail insert/update/delete.
- Use a third-party tool like DLRS (Declarative Lookup Rollup Summaries) — an open-source managed package that provides flow-like roll-up on lookups.
- Write a trigger — least preferred; flows are now the recommended declarative path.
The classic interview gotcha: a candidate proposes a roll-up summary on Account → Opportunity (which is a lookup, not master-detail) — and gets corrected by the interviewer.
Real scenario
“You want to show on each Account the number of open Opportunities and the total Amount of all Open Opportunities. How would you implement this?”
The relationship between Account and Opportunity is a lookup, not master-detail — so you cannot create a roll-up summary directly. Options:
- Flow (recommended declarative path): a record-triggered flow on Opportunity that, on create/update/delete, recalculates
Open_Opp_Count__candOpen_Opp_Amount__con the parent Account. - DLRS (if you prefer a managed package): define the roll-up declaratively, schedule full recalculations as needed.
- Apex trigger: works but harder to maintain than flow.
If you’re modeling a custom parent/child where the data shape allows it (e.g., Invoice → Invoice Line Item), use master-detail and get the roll-up for free.
Common interview follow-up: why is the roll-up summary option grayed out?
Often the answer is one of:
- The child relationship is a lookup, not master-detail.
- You haven’t yet created the master-detail field on the detail object — you must create the relationship first, then the master can offer the roll-up option.
- You’ve hit the per-object roll-up summary field limit (25).
- The field you’re trying to aggregate isn’t a supported type for the operation chosen.
- A cross-object dependency (formula referencing a field used in this roll-up) is blocking it.
Verified against: Salesforce Help — Roll-Up Summary Fields and Considerations for Roll-Up Summary Fields. Last reviewed 2026-05-17.