Sub topic 7
Building a summary report
This chapter assumes you can open Report Builder in Lightning Experience and pick a report type. It also assumes you know what a tabular report is and have seen a filter pane. Here you turn a flat list of rows into a summary report. You group the rows, choose what to calculate, and check that the numbers mean what you think they mean.
What a summary report is
A summary report is a tabular report with at least one row grouping. Salesforce sorts the records into groups, then calculates subtotals for each group and a grand total for the whole report. The detail rows stay available. You can show them or hide them with the Show Details toggle.
Each part of the report does a separate job:
- The report type decides which objects and fields exist.
- Filters decide which records are included.
- Groupings decide how the records are split.
- Summary fields decide what is calculated for each split.
The order matters. Filters run first, so a summary describes only the records that survive them.
Build the report step by step
This example answers the question "How much open pipeline do we have in each stage?"
- In Lightning Experience, open Reports and choose New Report.
- Select the Opportunities report type and start the report.
- In the Filters pane, keep the scope on All opportunities or narrow it to My team's opportunities. Add a filter such as Close Date equals THIS FISCAL YEAR. Add another to exclude closed records, for example Closed equals False.
- In the Outline pane, open the Group Rows box and add Stage.
- The report is now a summary report. Salesforce shows a Record Count column by default.
- Add Amount as a column if it is not there yet. Open the column menu and choose Summarize this Field. Select Sum, and also Average if you want it.
- Click Save & Run, then use Show Details to switch between groups with rows and groups alone.
Salesforce orders the groups alphabetically by the grouping field's values. For a picklist like Stage, this follows the picklist order. You can change the order. Sort a group by a summary value, such as Sum of Amount, to put the largest stage first.
Choosing summary functions
Record Count is available on every report. Other functions depend on the field type.
| Field type | Available summaries | Typical use |
|---|---|---|
| Currency, number, percent | Sum, Average, Min, Max | Pipeline total, average deal size |
| Date and date/time | Min, Max | Earliest and latest close date per group |
| Text, picklist, checkbox | None directly | Group by these fields, or count records |
Two details cause frequent confusion:
- Average is computed from the records in the group that have a value. A blank Amount is skipped, not treated as zero. Averages can therefore be higher than you expect when many records are blank.
- Record Count counts rows in the report. It does not count distinct accounts or contacts. This is the cause of the largest class of wrong numbers, covered below.
A custom summary formula can derive other measures. For example, this formula, built in a later chapter, returns the average amount per group:
AMOUNT:SUM / RowCountMultiple grouping levels
You can add more groupings to nest the data. Grouping Opportunities by Stage and then by Owner produces a subtotal for each stage and a subtotal for each owner inside it. In Lightning, a summary report supports up to three row grouping levels. A fourth dimension is a signal to consider a matrix report, which spreads one dimension across columns.
Grouping order changes the story. Stage then Owner answers "who holds each stage's pipeline?" Owner then Stage answers "how is each rep's pipeline spread?" The totals are the same, and the reading is different.
Date fields have their own grouping choice. When you group by Close Date, you choose a granularity such as Day, Calendar Month, Calendar Quarter, Fiscal Quarter, or Fiscal Year. Fiscal granularities use your org's fiscal year settings. If your fiscal year starts in a different month from the calendar year, the calendar and fiscal choices produce different groups from the same records. Pick the one your finance team uses.
The same result in SOQL
A summary report is conceptually a grouped aggregate. This SOQL returns the numbers a report grouped by Stage with Sum of Amount and Record Count would show:
SELECT StageName, SUM(Amount) total, COUNT(Id) cnt
FROM Opportunity
GROUP BY StageNameThe comparison helps in one case. When a report total looks wrong, ask what the equivalent query would be. If you cannot write a query that gives the same number, you probably misunderstand the grain of the report, meaning what one row represents.
Common errors and edge cases
Summing a parent field over child rows
Take an Accounts with Opportunities report type. One row appears per opportunity, and each row also carries the account's fields. Suppose you summarize Annual Revenue from the Account. An account with five opportunities contributes its revenue five times. The total is inflated, and nothing warns you.
The fix is to summarize only fields from the object whose row you are counting. For account-level measures, use an Accounts report, or use a report type where the account is the primary object and the child data is not duplicated.
Missing records
A report type has an inclusion rule. "Accounts with Opportunities" excludes accounts that have none. If a group seems to be missing, check the report type before you check the filters. The rule is built into the type and cannot be changed in the report.
Blank grouping values
Records with no value in the grouping field appear in a group labeled with a dash (-). Do not delete this group by mistake. It tells you how many records lack data. If you only want populated records, add a filter that excludes blanks, such as Stage not equal to nothing.
Filters that change meaning
Standard filters combine with AND by default. If you add three filters and the report goes empty, check the Filter Logic setting. A filter on a related field can also drop records that have no related row. This usually happens when the filter refers to a field on a child object.
Summaries and display limits
When details are shown, the report displays a limited number of detail rows (up to 2,000 in the run page), but the group summaries are still calculated over every matching record. A Sum of Amount is therefore not truncated by the display limit. Check the row count shown in the report header if you rely on the details. To limit the report to the top records, use Add Row Limit with a sort. This is useful for "top 10 deals" views, but note that it limits the rows used, so it changes the totals.
Grand total versus subtotal
A subtotal belongs to one group, and the grand total covers the whole report. Averages are not additive. The grand-total Average is computed over all records, not as the average of the group averages. If your groups have very different sizes, the two numbers differ a lot.
A short checklist
- Name the grain: what does one row of this report represent?
- Choose the report type that makes that row the primary object.
- Filter first, then group, then summarize.
- Summarize only fields that belong to the row's own object.
- Sort groups by the measure you care about.
- Reconcile the grand total against an independent number.
Exercise
An "Accounts with Opportunities" summary report is grouped by Account Owner. You add Sum of Account Annual Revenue. An owner's total looks far higher than the revenue of the accounts they own. What is the likely cause, and how do you fix it?
Show answer
The report has one row per opportunity, and the Account's Annual Revenue is repeated on every one of those rows. Accounts with many opportunities are counted many times. Fix it by summarizing a field from the opportunity (such as Amount), or by building the account-level measure in a report where the account is the row, such as an Accounts report. Then compare the total with a trusted figure.
Exercise
You group Opportunities by Stage and add Average of Amount. Several records in one stage have a blank Amount. Does the group's average treat the blanks as zero? What would you check?
Show answer
No. Blank values are skipped, so the average is computed only over records that have an Amount. Check Record Count against the number of records that have an amount. If the counts differ, the average describes only part of the group, and you may want to filter out or fix the blank records.