How to Create Roll-Up Summary Fields in Salesforce
Roll-up summary fields are used to calculate a value from related records and display it on a Master Record. The Roll-up field automatically looks for the change in related records and automatically updates the Master record. This can be created only when the relationship between Parent and child is ‘Master-Detail’ Relation. For Example, we have ‘Quote’ object, which his having a ‘Quote Line Item’ as Child Object. We can calculate the number of child objects exists for the ‘Quote’ and display them in the ‘Quote’ object. When a new ‘Quote Line Item’ is added, the roll-up summary field in ‘Quote’ is updated automatically.
Now, I will be creating a ‘Roll-up’ summary field in Quote object to count the number of line items created for that.
Below are the steps to be followed to create a Roll-up Summary Field in Salesforce:
Steps to Create a Roll-Up Summary Field:
- Navigate to Setup -> Build -> Customize -> Quotes -> Fields and click on New. Below screen will be shown
- Select ‘Roll-Up Summary’ and click on Next button. You will be navigated to below screen, where you have to provide the ‘Field Name’ and ‘Description’. Here I am providing Name as ‘Count’
- Click on Next button. You will be navigated to below screen
- Now, select the object which needs to be summarized. Here, I am summarizing ‘Quote Line Items’.
- Select the ‘Roll-up’ type. There are 4 types of Roll-Up:
- Count: It counts the number of child records existing for the parent record.
- Sum: When ‘Sum’ is selected, you have to provide ‘Field to Aggregate’. It contains the list of numeric fields in the Child object. Sum of all the line items will be calculated and it’ll be updated in the roll-up field.
- Min: It returns the Minimum value of a given field in all the child records
- Max: It returns the Maximum value of a given field in all the child records
- Here, I am selecting ‘Count’. We can also select particular records based on certain criteria based on our business requirement.
- I want to include all the records so, I have selected the first option.
- When we select ‘SUM’ or ‘MIN’ or ‘MAX’, we need to provide the ‘Field to Aggregate’, It is a picklist with the list of fields available on Child Record which can be used to perform the selected operation.
- The field types that are supported by ‘SUM’ are Percent, Number and Currency.
- The field types that are supported by ‘Min’ and ‘Max’ Percent, Number, Currency, Date and Date/Time.
- Select the ‘Field to Aggregate’ in case of Sum, Min or Max and click on ‘Next’ button. You will be navigated to below screen.
- Set the field-level security to determine whether the field should be visible for specific profiles, and click Next. You will be navigated to below screen.
- Click on ‘Save’ button. Now, the Roll-up summary field is created on ‘Quote’.
- Navigate to ‘Quote’. There you can find the ‘Count’ field which returns the count of Child records existing for a particular ‘Quote’ Master record.
- Below screen shows the number of child records existing for the ‘Quote’ Master record.
- In the above screen, ‘Count’ in Quote is ‘3’ and the number of quote line items are 3.
- In this way, we can create a ‘Roll-up’ summary field on a Parent record to calculate Count, Sum, Min or Max of child records without writing any code.
Limitations on Roll-Up Summary Fields in Salesforce:
- A Roll-up summary can be created only on records which are having Master-Detail Relationship
- Only 25 roll-up summary fields can be created for an object
- Long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields can’t be used in roll-up summary filters
- A Master-detail relationship can’t be changed to lookup relationship after creating a roll-up summary field on an object
- When you refer to a roll-up summary field in a list view or report, you can’t use certain qualifiers, including: Starts with Contains, Does not contain, Includes, Excludes and Within.
Now, you can easily integrate your Salesforce CRM with the back-end ERP system to automate the business process!