Sub topic 6
Summarizing fields within groups
This chapter assumes you can open Report Builder in Lightning Experience and know the basics of objects, fields, and records. It also assumes you have already grouped rows in a report. Here you will add calculations to those groups.
What a summary does
A summary is a calculation that Salesforce runs over the rows in each group. Without groupings, you see one list of rows. With a grouping, you can also see one number per group, such as total Amount for each Stage.
Each numeric field can be summarized in these ways:
| Summary | What it returns | Typical use |
|---|---|---|
| Sum | Total of the field across the group | Total pipeline value |
| Average | Sum divided by the number of rows with a value | Average deal size |
| Min | Smallest value in the group | Earliest or lowest amount |
| Max | Largest value in the group | Biggest deal |
| Record Count | Number of rows in the group | Number of opportunities |
Record Count is available in every report. The other four apply only to number, currency, and percent fields. Min and Max can also be used with date fields.
Adding a summary
- Open the report in the report builder and make sure it has at least one grouping.
- Open the Outline panel.
- Under Columns, open the menu for a numeric field such as Amount.
- Choose Summarize this Field, then select Sum, Average, Min, or Max.
Salesforce shows the result on each group's subtotal line and on the grand total line at the bottom. You can select several summaries for the same field.
Worked example
Suppose a summary report on Opportunities is grouped by Stage. You summarize Amount with Sum and Average, and you keep Record Count on.
| Stage | Opportunities | Sum of Amount | Average of Amount |
|---|---|---|---|
| Prospecting | 4 | 40,000 | 10,000 |
| Negotiation | 2 | 90,000 | 45,000 |
| Closed Won | 3 | 60,000 | 20,000 |
The grand total is 9 records and 190,000 in Amount. The grand total average is about 21,111, which is 190,000 divided by 9. It is not the average of the three group averages. The overall average is computed from all rows, so groups with more rows count for more.
Common errors
- Averages that ignore blank values. Average divides by the number of rows that have a value in the field, not by the Record Count. If two of four opportunities have no Amount, the average uses two rows. Check this before you compare an average against a sum divided by Record Count.
- Summing the wrong field. Report types can expose several similarly named currency fields. Confirm the field label before you summarize it.
- Mixed currencies. In an organization with multiple currencies, summaries are converted to a single currency. Rates can differ from what you expect, so check the report's currency setting.
- Expecting a summary without a grouping. In a tabular report, you can show only the grand total. Subtotals need groupings.
Why this matters
Summaries turn a grouped list into an answer. They also decide what a chart can show. A chart built on a summary report plots one of the summaries per group, so the summaries you choose here become the chart values later.
Exercise
A report is grouped by Owner. Owner A has three opportunities with Amounts of 10,000, 20,000, and blank. What are the Sum, Average, and Record Count for Owner A?
Show answer
Sum is 30,000. Average is 15,000, because the blank row is ignored and 30,000 is divided by 2. Record Count is 3, because the row still exists.
Exercise
Why is the grand total average in a report not the same as the average of the group averages?
Show answer
The grand total average is calculated across all rows. A group with more rows has more influence on it, while the average of group averages treats every group equally.