Business Logic and Process Automation · Topic 2 of 7
Roll-Up Summary Fields
Salesforce roll-up summary fields: COUNT, SUM, MIN and MAX of detail records, filter criteria, master-detail requirement and options when lookups are used.
- 4 min
- Roll-up summary fields need a master-detail relationship and live on the master.
- Four functions: COUNT, SUM, MIN, MAX; filter criteria are optional.
- SUM works on number, currency and percent; MIN and MAX also on dates.
What it is
A roll-up summary field on a master record calculates a value from its detail records in a master-detail relationship. It can count the detail records or find the sum, minimum or maximum of one of their fields.
It is the declarative way to show child data on a parent, such as the number of open job applications on a position or the total value of line items on an order.
How it works
Roll-up types
| Type | Result | Field types it summarizes |
|---|---|---|
| COUNT | Number of detail records | Any detail record |
| SUM | Total of a field | Number, currency, percent |
| MIN | Lowest value of a field | Number, currency, percent, date, date/time |
| MAX | Highest value of a field | Number, currency, percent, date, date/time |
Filter criteria
A roll-up can include all detail records or only those that meet filter criteria, such as Status equals Open. Use filters to build several roll-ups on one master, for example Open Applications and Closed Applications.
Where roll-up summary fields work
- The relationship must be master-detail. Lookup relationships do not support roll-up summary fields.
- Roll-up summaries are also available on some standard relationships, such as Account to Opportunity and Opportunity to Opportunity Product.
- The value is recalculated when detail records are created, edited, deleted or undeleted.
- The roll-up summary value can be used in formulas, validation rules, reports and automation on the master.
What a roll-up cannot summarize
- A formula field on the detail that uses TODAY or NOW, or other values that change without the record being saved.
- Cross-object formula fields on the detail that reference other objects.
- Fields on records related through a lookup.
Options when the relationship is a lookup
If converting the lookup to master-detail is not possible, for example because child records need their own owners, the summary can be maintained another way:
| Option | How |
|---|---|
| Record-triggered flow | When a child is created, changed or deleted, recalculate and update a field on the parent |
| AgentExchange tool | A packaged roll-up tool from AgentExchange |
| Apex | A trigger written by a developer |
The flow option is declarative, but you must handle every change that affects the total, including deletes and reparenting.
Considerations
- Changing a roll-up summary field or the field it summarizes can recalculate values across many records, which can take time.
- You cannot convert a master-detail relationship to a lookup while roll-up summary fields depend on it.
- Each object allows only a limited number of roll-up summary fields, so plan them.
A worked example: a recruiting app has Position__c as the master of Job_Application__c. Hiring managers want each position to show the number of applications in Interview status and the date of the latest application. The builder creates a COUNT roll-up with the filter Status equals Interview, and a MAX roll-up of the application's created date.
"Show the total or count of child records on the parent" with a master-detail relationship is a roll-up summary field. With a lookup, it becomes a record-triggered flow.
How the exam asks about this
- "Show the total amount of all line items on the invoice." SUM roll-up summary.
- "Count only closed cases" on a custom master. COUNT with filter criteria.
- "The relationship is a lookup and must stay a lookup." A record-triggered flow on the child.
What to remember for the exam
- Roll-up summary fields need a master-detail relationship and live on the master.
- Four functions: COUNT, SUM, MIN, MAX; filter criteria are optional.
- SUM works on number, currency and percent; MIN and MAX also on dates.
- Detail formulas with TODAY, NOW or cross-object references cannot be summarized.
- With a lookup, use a record-triggered flow or a packaged tool instead.
A master-detail relationship with roll-up summary fields cannot be converted to a lookup until those roll-up fields are deleted.
Common mistakes
Creating a roll-up on a lookup relationship. It is not available; use master-detail or a flow.
Putting the roll-up field on the child. It belongs on the master.
Forgetting deletes when replacing a roll-up with a flow. The total must also change when a child is deleted.
Check yourself
Which four functions can a roll-up summary field use?
COUNT, SUM, MIN and MAX.
Which relationship type does a roll-up summary field require?
Master-detail, with the field created on the master object.
How can a builder total child values when the relationship must stay a lookup?
Use a record-triggered flow on the child that updates the parent, or a packaged roll-up tool.
Topic 2 of 7 in Business Logic and Process Automation
Test yourself on Business Logic and Process Automation
The full Salesforce Platform App Builder question bank has 648 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Salesforce. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.