Loading
Salesforce now sends email only from verified domains. Read More
Extend Salesforce with Clicks, Not Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Roll-Up Summary Field

          Roll-Up Summary Field

          A roll-up summary field calculates values from related records, such as those in a related list. You can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. For example, you want to display the sum of invoice amounts for all related invoice custom object records in an account’s Invoices related list. You can display this total in a custom account field called Total Invoice Amount.

          Required Editions

          Important
          Important Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.
          Available in: both Salesforce Classic and Lightning Experience
          Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions

          You can perform different types of calculations with a roll-up summary field. You can count the number of detail records related to a master record. Or, you can calculate the sum, minimum value, or maximum value of a field in the detail records. See Create a Roll-Up Summary Field.

          Before you begin creating roll-up summary fields for your org, review the implementation tips and best practices.

          Administration

          • Create roll-up summary fields on:
            • Any custom object that is on the master side of a master-detail relationship
            • Any standard object that is on the master side of a master-detail relationship with a custom object
            • Opportunities using the values of opportunity products related to the opportunity
            • Accounts using the values of related opportunities
            • Campaigns using campaign member status or the values of campaign member custom fields
              Note
              Note Campaign member custom formula fields that reference fields derived from leads or contacts aren’t supported.
          • The types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example:
            • Number, currency, and percent fields are available when you select SUM as the roll-up type.
            • Number, currency, percent, date, and date/time fields are available when you select MIN or MAX as the roll-up type.
          • Sometimes you can’t change the field type of a field that you reference in a roll-up summary field.
          • Make sure that the filter for your roll-up summary doesn’t encounter a formula field that results in #Error!. If one of your filter criteria uses a formula field that results in an error, no matches are returned for that filter criterion. For example, your roll-up summary filter is “Formula Field equals 10”. Two records contain errors, and one contains the value “10” in that field. In this case, your summary includes only the record with the value “10.”
          • Salesforce doesn’t recalculate the value of campaign roll-up summary fields when a lead or contact is deleted. Select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value.
          • You can’t use long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields in the field column of roll-up summary filters.
          • Auto number fields aren’t available as the field to aggregate in a roll-up summary field.
          • After you create a roll-up summary field on an object, you can’t convert the object’s master-detail relationship into a lookup relationship.
          • Roll-up summary fields aren’t available for mapping lead fields of converted leads.

          Management

          • If a roll-up summary field doesn’t contain cross-object field references or functions that derive values on the fly, such as NOW or TODAY, it can calculate the values of formula fields.
            Note
            Note The value of a formula field can result in #Error!, which affects the summarized total. If your roll-up summary type is COUNT, records are included regardless of whether they contain a formula field with an error. However, when the Field to Aggregate is a formula field that results in #Error!, calculations of type MIN, MAX, and SUM exclude those formula values.
          • Changes to the value of a roll-up summary field can trigger assignment rules to run. If a roll-up summary field is part of the criteria in an assignment rule, the field’s new value is used to evaluate whether to reassign the record.
          • These changes cause a mass recalculation of roll-up summary fields. However, when these changes cause a recalculation of roll-up summary values, the recalculation doesn’t trigger workflow rules and field validations.
            • Changing the roll-up summary definition, such as the object, function, or field being aggregated
            • Changing the expression of a formula field referenced in a roll-up summary field
            • Replacing picklist values for picklist fields referenced in the roll-up summary filter
            • Changing picklist record type definitions
            • Changing currency conversion rates
            • Changing price book entries
            • Selecting the Force a mass recalculation of this field option on the edit page of the roll-up summary field
          • Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors.
          • You aren’t prevented from creating roll-up summary fields that can result in invalid values, such as February 29 in a non-leap year. If a roll-up summary field results in an invalid value, the value isn’t recalculated. The field continues to display with an invalid roll-up summary icon (invalid_roll-up_summary) until you change the values being summarized.
          • If your org uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record.
          • Changing a conversion rate triggers roll-up summary fields to recalculate. If you’re using multiple currencies, we recommend changing the conversion rate from Manage Currencies in Setup, and not from the API. If you change the rate from the API, related jobs that are less than 24 hours old can interfere with your change.
          • If your org has advanced currency management enabled, currency roll-up summary fields are invalid if they’re on accounts and summarizing opportunity values, on opportunities and summarizing custom object values, or on quotes and summarizing custom object values.
          • Salesforce prevents users from saving a record if it invalidates a related record. For example, a master record has a validation rule that requires the roll-up summary field value to be greater than 100. If the user’s change to a related child record would put the value over 100, the user can’t save the record.
          • If a lookup field references a record that was deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship.

            To be used in a roll-up summary field with a Roll-Up Type of COUNT or SUM, the lookup field must have the What to do if the lookup record is deleted? option set to Don’t allow deletion of the lookup record that’s part of a lookup relationship. If the option Clear the value of this field. You can’t choose this option if you make the field required is selected, you can’t create a COUNT or SUM roll-up summary field that pulls data from your lookup field.

          • When multiple currencies are enabled in an org and corporate currency is different from the currency set on the record, the UI and the database for roll-up summary field values can display different decimal values. Values in the UI are displayed as two decimal places, whereas the database displays the exact value, which can be several decimal places. This behavior is due to the way values are stored in the database. The UI precision doesn’t affect the precision of the database, which is a floating-point value.

            In some cases, there can be small numerical remainders after deletion or filtering of records when you use SUM as the roll-up type. To correct the value, recalculate the value manually by selecting the Force a mass recalculation of this field option on the edit page of the roll-up summary field.

          • When you delete a roll-up summary field using Metadata API, the field isn’t saved in the Recycle Bin. The field is purged even if you don’t set the purgeOnDelete deployment option to true.

          Best Practices

          • Apply field-level security to your roll-up summary fields if they calculate values that you don’t want visible to users. Fields that your users can’t see due to field-level security settings on the detail record are still calculated in a roll-up summary field.
          • If you have validation rules, consider how they affect roll-up summary fields. The value in a roll-up summary field changes when the values in the detail records change. So, validation errors can display when saving either the detail or master record.
          • Because roll-up summary fields aren’t displayed on edit pages, you can use them in validation rules but not as the error location for your validation.
          • Avoid referencing a roll-up summary field from a child record. The roll-up summary fields referenced from a child record can have outdated values because the parent record isn’t updated. Instead, reference roll-up summary fields from a parent record. Your roll-up summary fields always have updated values because that rule runs after the parent value is updated.

            If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater.

            AND(ISNEW(), Sample.Line_Count__c >= 25)
          • Plan your implementation of roll-up summary fields carefully before creating them. After created, you can’t change the detail object selected or delete any field referenced in your roll-up summary definition.
          • Advanced currency management affects roll-up summary fields. If your org enables advanced currency management, delete the currency roll-up summary fields on accounts that summarize opportunity values and on opportunities that summarize custom object values. Otherwise, the fields continue to display with an invalid roll-up summary icon because their values are no longer calculated.
          • Automatically derived fields, such as current date or current user, aren’t allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields.
          • 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
            • Within
           
          Loading
          Salesforce Help | Article