Sub topic 12
Common groupings and cross-block comparisons
This chapter assumes you can build a summary report and a matrix report, and that you know what a report type is. It also assumes you have seen a joined report with more than one block. Here you will learn how a common grouping lines up blocks, how to compare numbers across blocks, and where this approach breaks.
Why common groupings exist
A joined report holds up to five blocks. Each block has its own report type, its own filters, and its own columns. Blocks do not share rows. An Opportunities block and a Cases block are two separate result sets that happen to sit on one page.
Without something to tie them together, you would read the blocks side by side and match them by eye. A common grouping solves this. It is a grouping field that exists in every block, which lets the report align the blocks on the same values.
Typical examples:
- Close Date by calendar month, so that pipeline and closed-won revenue share a time axis.
- Account Name, so that opportunities, cases, and activities appear under the same account.
- Owner, so that each rep shows quota-related and service-related numbers together.
How a common grouping is defined
In the joined report builder, you group inside a block, then the builder offers to treat the field as common. Salesforce lists fields as common only when every block can supply them. A field is available when each block's report type exposes a field that matches it.
Two kinds of fields can be common:
- A field that exists in all report types by the same definition, such as Account Name, Owner, or a date.
- A field from a shared parent object. Opportunities and Cases both look up to Account, so both blocks can group by Account.
The grouping shows up above the blocks. Each group value appears once, with every block's rows listed under it.
Cross-block formulas
A normal custom summary formula works inside one report and one block. A joined report adds cross-block formulas. These are formulas that reference summary fields from different blocks, so you can combine them.
Cross-block formulas use a block-qualified field reference. The form is B1#AMOUNT:SUM, where B1 is the block number. A ratio of won revenue to open pipeline might read:
B1#AMOUNT:SUM / B0#AMOUNT:SUMIn practice you build these in the formula editor by choosing the block and summary from the lists, so you do not need to memorize the syntax. Some points to know:
- A cross-block formula is calculated at the grouping level. If the report is grouped by Account Name, the ratio is computed per account.
- It can also be calculated at the grand-total level, which gives one overall ratio.
- Each block must have the summary field you reference. If a block has no summed Amount, there is nothing to reference.
- The result can be shown as a number, currency, or percent.
Compare this with the single-block formulas from the earlier chapter. Both of these are single-block patterns:
AMOUNT:SUM / RowCountAMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE)The first returns the average opportunity amount per group. The second returns the change in summed Amount against the previous Close Date group. A cross-block formula extends the same idea by letting the numerator and denominator come from different blocks.
Worked example: pipeline versus closed revenue
Suppose you want to see, by month, how much was closed-won and how much is still open. You then want a conversion-style ratio.
- Create a joined report from the Opportunities report type.
- In block 1, filter Stage to closed-won, and add the Amount summary.
- Add a second block from the same report type. Filter Stage to open stages, and add the Amount summary.
- Group both blocks by Close Date, using calendar month.
- Confirm that Close Date is shown as a common grouping.
- Add a cross-block formula that divides the first block's summed Amount by the second block's summed Amount.
Each month now appears once. Under it you see the closed-won total, the open total, and the ratio.
A matching SOQL view of one block is useful for checking your numbers. The query below returns the closed-won totals by month. It would match block 1 if the filter used the same stage rule.
SELECT CALENDAR_MONTH(CloseDate) mon, SUM(Amount) total
FROM Opportunity
WHERE IsWon = true
GROUP BY CALENDAR_MONTH(CloseDate)Note that CALENDAR_MONTH returns only the month number. If the report spans more than one year, January of two different years collapses into one group in this query. Add CALENDAR_YEAR(CloseDate) to the select list and the GROUP BY clause to keep them apart.
Choosing what to group on
The grouping you choose decides what the report can compare. Use this table as a starting point.
| Goal | Common grouping | Notes |
|---|---|---|
| Compare periods | Close Date or Created Date by month or quarter | Use the same date field and granularity in every block |
| Compare people | Owner | Owner names must match across report types |
| Compare customers | Account Name | Needs a report type that includes the account |
| Compare categories | A picklist or bucket field | A bucket in one block does not carry to others |
Limits and gotchas
Common groupings are convenient, but the model has real constraints.
- Block limit. A joined report has at most five blocks. Plan which comparisons matter before you add blocks.
- Date granularity must match. Month in one block and quarter in another will not share a common grouping. Set the same granularity everywhere.
- Filters are per block. A report-level filter applies to all blocks, but block filters apply to only one. A cross-block ratio is only meaningful when you understand which filters each side carries.
- Missing group values. If an account has opportunities but no cases, the group may show an empty block for cases. The formula then divides by nothing. Treat blank denominators deliberately.
- Division by zero. A cross-block formula that divides by a block with no rows returns an error or a blank. Guard it with an
IFtest on the denominator. - Buckets are block-local. A bucket field created in one block is not available to the other blocks. If you want a common bucketed category, you cannot get it from buckets alone. Use a real field, such as a picklist, or create the bucket in each block and group on a field they both expose.
- Joined reports and charts. Charts on joined reports are limited. Each chart is tied to a block, and you cannot freely mix blocks in one chart. Dashboards also cannot use a joined report as a source in the same way as they use summary or matrix reports. Test this early if a dashboard is the goal.
Guarding a cross-block ratio
Use a conditional so that empty groups do not produce errors. The idea is to return zero when the denominator is zero.
IF(B0#AMOUNT:SUM = 0, 0, B1#AMOUNT:SUM / B0#AMOUNT:SUM)If you prefer to show a blank instead of zero, check how your org handles null in formulas before choosing. Zero can look like a real result, so label it clearly.
When a joined report is the wrong tool
A joined report is not the only way to compare two measures by the same group.
- If both measures come from one object, a single summary or matrix report with two summary fields is simpler.
- If you need the report on a dashboard, a summary or matrix report is better supported.
- If the measures come from different, unrelated objects, a joined report with a common grouping is the right fit.
Exercise
You built a joined report with an Opportunities block and a Cases block. You want to group both by Account Name and compute cases per won opportunity for each account. What must be true for Account Name to be a common grouping, and how should the ratio formula handle accounts with no won opportunities?
Show answer
Both blocks' report types must expose Account Name, either directly or through the parent Account that Opportunities and Cases both reference, and both blocks must be grouped by it. The cross-block formula divides the Cases block's record count by the Opportunities block's record count. Because some accounts have no won opportunities, wrap it in a conditional such as IF(denominator = 0, 0, numerator / denominator) so those accounts return zero or a blank instead of an error.
Exercise
A teammate groups block 1 by Close Date by month and block 2 by Close Date by quarter, then cannot find Close Date offered as a common grouping. What is the cause and the fix?
Show answer
The date granularity differs between blocks, so the groupings do not match. Set both blocks to the same granularity, for example calendar month, and Close Date becomes available as a common grouping.