Choosing between roll-up summaries and Formula Fields in Salesforce (opens in a new tab)
You will know when a value needs a roll-up summary, a Formula Field, or a Flow or Apex alternative, based on relationship type and the shape of the calculation.
Why read this
The piece ends with a short decision checklist.
Roll-up summary
- Aggregates child records
- Master-detail only
- Recalculates on child change
- No lookup relationships
Formula Field
- Uses one record's fields
- Lookup or master-detail
- Recalculates on each view
- Never stale at read time
The article distinguishes roll-up summary fields from Formula Fields. A roll-up summary sits on a parent record and aggregates its child records through count, sum, min or max. It works only on master-detail relationships and recalculates when a child changes. A Formula Field calculates from a single record’s own fields and related parent fields, recalculating each time the record is viewed, and works on both lookup and master-detail relationships.
Roll-ups suit jobs such as counting open cases on an account or summing opportunity amounts, and they stay accurate without extra queries or flows. Their limits are basic filter criteria, no more than one relationship level, and no support for lookup relationships. Formulas suit record-level logic such as age fields, name concatenation or flags driven by a few fields. The trap is formulas that reach across many objects, which become hard to read and can slow List Views and reports on large data volumes.
The article closes with a checklist: many children into one parent number points to a roll-up, a value derived from the record itself points to a formula, a lookup relationship needs Flow or similar tooling, and complex filtering or cross-object aggregation needs Flow or Apex.
Read the original at dev.to (opens in a new tab)