How to Create Rollup Summary Fields in Salesforce



Roll up Summary

Roll-up summary fields are based on master-detail relationships, it’s useful to review object relationships before creating a roll-up summary field.

There are a few different types of summaries you can use.

Type Description
COUNT Totals the number of related records.
SUM Totals the values in the field you select in the Field to Aggregate option. Only number, currency, and percent fields are available.
MIN Displays the lowest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
MAX Displays the highest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.

Master-Detail Relationships

Master-detail relationships closely link objects together so that the master record controls specific behaviors of the detail and subdetail record.

You define a roll-up summary field on the object that is on the master side of a master-detail relationship. For example, you can create a roll-up summary field on the Account object, summarizing related opportunities:

Creating the Summary Field

  1. From Setup, open Object Manager and click Account.
  2. On the left sidebar, click Fields & Relationships.
  3. Click New.
  4. Choose the Roll-Up Summary field type, and click Next.
  5. For Field Label, enter Sum of Opportunities and click Next.
  6. The Summarized Object is the detail object that you want to summarize. Choose Opportunities.
  7. Choose the SUM summary type and choose Amount as the Field to Aggregate.
  8. Click NextNext, and Save.

After this you can find the field on the account and it will show the sum of the opportunities which is related to the account.

You can do the same to custom objects by creating Master Detail relationship between them.