I have a confusion on whether to go for formula fields or roll up summary fields in some scenarios. As we can calculate the aggregate values in formula fields also, then why/when should we go for Roll up summary. What are the differences between them.
A Rollup Summary field is used to calculate the sum of a fields in the child object record. It is compulsory to be in a Master-Detail relationship to use the rollup summary. A rollup summary field is always created on Master record.(Parent to Child).
Example. You have an Account and multiple Contacts under that Account. Each of the Contact have a number field on it say
Contacted People. Now on the Account you can create a Rollup summary to check the Number of
Contacted Peoplevia all your contacts.
Where else a formula field is mostly used for calculations with in a certain object. And it is child to Parent .
While formula fields calculate values using fields within a single record, roll-up summary fields calculate values from a set of related records, such as those in a related list. You can create roll-up summary fields that automatically display a value on a master record based on the values of records in a detail record. These detail records must be directly related to the master through a master-detail relationship.
For example, you might want:
- A custom field(rollup summary field) in Account obj that calculates the total of all related
Account and Opportunity are in master detail relationship.
Rollup summary field is read-only field that displays the sum, minimum, or maximum value of a field in a related list or the record count of all records listed in a related list