Roll-up summary fields versus flow for aggregating child records
Key Takeaway
Apart from a few standard pairs, a roll-up summary field works only through a master-detail relationship. When the parent and child are linked by a lookup relationship, an after-save record-triggered flow on the child object can query the related child records, calculate the total, and update the parent.
A roll-up summary field and a record-triggered flow are two declarative ways to show a value from child records on a parent record. A roll-up summary field sits on the master record and calculates a COUNT, SUM, MIN or MAX of its detail records. Outside a few standard pairs, a roll-up summary field works only through a master-detail relationship. A record-triggered flow can query records, run logic and update another record, so it can handle needs a roll-up summary field can't. The trade-off is that you build the flow's logic yourself and choose when it runs.
What a roll-up summary field does
A roll-up summary field lives on the master record and calculates a value from the master's related detail records. The detail object must be related to the master through a master-detail relationship.
Each roll-up summary field uses one of four roll-up types.
| What it shows | |
|---|---|
| COUNT | The number of related detail records |
| SUM | The total of a number, currency or percent field |
| MIN | The lowest value of a number, currency, percent, date or date/time field |
| MAX | The highest value of a number, currency, percent, date or date/time field |
Filter criteria let a roll-up summary field include only a selected group of detail records instead of all of them.
You can create a roll-up summary field on any custom object on the master side of a master-detail relationship. You can also create one on any standard object that is the master of a custom object. A few standard pairs also work:
- Opportunities can roll up values from opportunity products.
- Accounts can roll up values from related opportunities.
- Campaigns can roll up values from campaign member status or campaign member custom fields.
A training company has a custom Course object that is the master of a custom Enrollment object. The admin adds a roll-up summary field called Active Students to Course. The roll-up type is COUNT. The filter includes only enrollments whose Status is Active. An enrollment with the Status Cancelled isn't counted, so each course shows only its active students.