---
title: "SFDC: Add a Rollup Summary Field"  
description: "In my last post SFDC: Add a formula field, we see how to add a formula field and get the total of each line item fieldAnother thing that's missing fro"  
author: "Anonymous User"  
published: 2015-03-17  
updated: 2018-02-22  
canonical: https://www.mindstick.com/blog/10837/sfdc-add-a-rollup-summary-field  
category: "sales force"  
tags: ["cloud computing", "cloud", "cloud development", "sfdc", "dev-401"]  
reading_time: 2 minutes  

---

# SFDC: Add a Rollup Summary Field

In my last post [*SFDC: Add a formula field*](https://www.mindstick.com/blog/10835/SFDC%20Add%20a%20formula%20field#.VQfa7ma6bIU), we see how to add a formula field and get the total of each line item field

Another thing that's [missing](https://answers.mindstick.com/qa/52138/international-missing-children-s-day-2019-was-observed-on) from the Invoice is a field that aggregates all of the line items into one big invoice total. This is easy to do if the [objects](https://www.mindstick.com/forum/145447/what-are-objects) are in a master-detail [relationship](https://yourviews.mindstick.com/view/80835/phubbing-is-the-relationship-killer) because you can use a roll-up [summary](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) field.

##### Calculate a Total With a Roll-Up Summary Field

##

Now that you have the total for each line item, it makes sense to add them all to get the invoice total. Because the line items have a master-detail relationship with the invoice, you can use a roll-up summary field to calculate this value. The roll-up summary is a special type of field that lets you [aggregate](https://www.mindstick.com/blog/52/aggregate-functions-in-database) information about related detail (child) objects. In this case, you want to sum the value of each line item.

1. Navigate back to the Invoice custom object page from Setup by clicking Create > Objects and then clicking Invoice.
2. In the Custom Fields & [Relationships](https://www.mindstick.com/blog/11850/how-to-build-stronger-relationships-with-your-employees) related list click New.
3. Choose Roll-Up Summary as the data type, and click Next.
4. For the Field Label field, enter Invoice Total, and click Next.
5. In the Summarized Object list choose Line Items.
6. For Roll Up Type, select Sum.
7. In the Field to Aggregate list choose Line Item Total.
8. Verify that [your screen](https://answers.mindstick.com/qa/103593/how-to-sharing-your-screen-on-skype) looks like this. Then click Next, Next, and Save.

![SFDC: Add a Rollup Summary Field](https://www.mindstick.com/blogs/d6f0bb66-b32b-4ab7-ba2b-892ca659339f/images/ad3109c9-d48f-47f6-ad61-67a5f34722d9.png)

#### Try out the App:

##

To see the new Invoice Total formula field in action, you only need to examine an invoice.

1. Click the Invoices tab and then click an existing invoice.
2. Notice the new Invoice Total field that “rolls up” all the values from the detail object’s Line Item Totals.
3. To get the Line Item Total field to appear on the detail page, you’ll have to edit the page layout. (If you haven’t done that yet, see SFDC: Modify a Page Layout). When you do, it should look like the following image.

![SFDC: Add a Rollup Summary Field](https://www.mindstick.com/blogs/d6f0bb66-b32b-4ab7-ba2b-892ca659339f/images/6dab7689-bdbc-4a8d-9e95-c55b0f23cc53.png)

**This [document](https://www.mindstick.com/articles/328642/what-to-consider-while-choosing-a-software-documentation-tool) is referred from [salesforce help tutorials](http://www.salesforce.com/us/developer/docs/workbook/index.htm)

---

Original Source: https://www.mindstick.com/blog/10837/sfdc-add-a-rollup-summary-field

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
