Playing With A Roll-Up Summary Fields
What is Roll-up Summary Fields?
Roll-up summary field is used to perform aggregate functions(is a function where the values of multiple child/related records are grouped together to form a single summary value on Parent Object).
You can create roll-up summary fields on Parent object(it must be Parent object only of a master-detail relationship)that automatically display a value on a master record based on the values of records in a detail record. For example, a custom field called “Total Line Item Sum” displays the sum of all the Line items associated with a single Invoice Object’s record, which means Line items are the related list for the invoice custom object.
You can perform different types of operations with your roll-up summary fields based on the requirement. You can count the number of detail/child records related to a master record, or calculate the sum, minimum value, or maximum value of a field in the detail/child records.
How to create a Rollup-Summary Field
Step 1. Go to your Master object (e.g. here we are choosing Invoice object, as you knew our Invoice Object is a Master Object, in a master detail relationship) and add new custom Roll-Up Summary field from the Data Type and click Next button.
Step 2. Fill the Field Label, Field Name and click Next button
Step 3. Select the summarized object (e.g. here we are choosing Line Item custom object as summarized object) and Roll-Up type (e.g here we are choosing rollup type as sum) and select Field to Aggregate (e.g here we are choosing Line Item Price) and click Next button.
Step 4. Select the field lebel security and click Next button
Step 5. Select the layout and click Save button
Create roll-up summary fields on:
- Any custom object that is on the master side of a master-detail relationship only on that object you can create roll-up summary field
- Any standard object which is on the master side of a master-detail relationship with a custom object
- Accounts using the values of its related opportunities
- Campaigns using campaign member status/the values of campaign member custom fields
- Campaign member custom formula fields that reference fields derived from leads/contacts are not supported.
The data types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example:
Currency, number and percent fields are available when you select SUM as the roll-up type.
Currency, number, percent, date, and date/time fields are available when you select MIN/MAX operation as roll-up summery type.
You may not be able to change the field type of a field that you reference in your roll-up summary field.