Roll-Up Summary Fields in Salesforce

Roll-Up summary fields in Salesforce are the elevated version of the formula fields. The formula fields show the values calculated from different fields from a single record. While the roll-up summary fields, calculate the values from a given set of related records, similar to the related list. The roll-up summary fields can be created to display the value on a master record, calculated on the values of records that is there is a detailed record, provided that the detail records are directly linked to the master records based on master-detail relationship.

Different types of calculations can be performed with the help of roll-up summary fields. For instance, we can count the detail records that are related to a particular master record. You can also calculate the maximum value or the minimum value of a field that is part of the detail records. A good example use case will be a custom sales field, that will calculate the value of the total raised leads. Another good use case will be custom sales fields, where the invoices have been already generated.

How to define a roll-up summary fields in Salesforce

Before you even start defining a roll-up summary field, you have to note that there needs to be master-details relationships, and roll-up summary fields rely on these relationships. The key reason behind this is, it has to visualize the relationships that exist between the objects, before a roll-up summary filed is created.

With the help of master-detail relationships, the master record can control certain behaviors of the detail record. When you define roll-up summary fields in Salesforce, it needs to be defined on the object that belongs to the master, as per the master-detail relationship. A good example will be creating a roll-up summary field on the Account object, that will calculate the total value of opportunities.

roll up 1

Some of the common forms of summaries that are used for the roll-up field are listed below.

  • Count- It returns the count of the total number of related records.
  • Sum- It sums the values in the field that is selected as “Field to Aggregate”. Only three options are available for SUM, which is currency, percent, and number.
  • Min- It shows up the lowest value of the field, which is selected as the “Field to Aggregate” option. This option is there for currency, date, time, percent, and number.
  • Max- It shows up the highest value of the field, which is selected as the “Field to Aggregate” option. This option is there for currency, date, time, percent, and number.

Steps to create Roll-Up Summary Fields in Salesforce

  • To create the summary field, go to Setup, and then open the Object Manager.
  • Now select the object on which the summary filed will be created. So, for example, if you are looking to create the summary filed on the Account object, then select “Account” from the object manager.
  • Once the object is selected, click on “Fields & Relationships”, which will be located on the left sidebar. Click on “New”.
  • In the next step choose the roll-up summary field type, and click on “Next”.
  • Now we have to define the label of the field, which should be meaningful and resemble the purpose of creating the summary field.
  • In the next screen chose opportunities. In the next screen select the summary type along with the field that will be selected as the field to aggregate. So, if you are summing up the opportunities for a particular account, then select SUM as the summary type, and “Amount” as the filed that will be selected as “Field to Aggregate”. 
  • Click “Next” and complete the wizard, and then save it.

Common use cases

New users might be a bit confused between Formula and roll-up summary fields. So, lets quickly check some of the use cases, that will give a fair idea on the usage of the roll-up summary fields.

  • Date of creation of opportunity: There might a requirement where we might want to know the earliest date of an opportunity, that was created for an account. We can create a rollup field on the Accounts object, and find the earliest date of the opportunity creation.
  • Sum of the prices for all products in an opportunity: We might be interested to know the total price of all the products in a particular opportunity. To get this, we can create a rollup field on the Opportunities object.

Summary fields provided an added level of customization for specific business needs. However, the main disadvantage is, it is limited to four types, and some of the key types such as text and average are not supported. Also, whenever the child record or child object is deleted, the calculation on the summary filed is not automatically updated, and this needs to be done manually. Another notable drawback is, lookup relationships are not supported for summary fields. Some of the limitations of the native summary fields option can be removed with the help of Rollup Helper, which is a third party plugin available on AppExchange.