You can group and subtotal columns of merged data using the “Group” and “Subtotal” parameters. For more information, see Excel Merge Field Parameters.
In the following example, we’ll demonstrate how to group and subtotal Opportunity Line Items by Product Family.
Step 1: Non-Grouped Template
Start with a simple template that displays the non-grouped data.
Step 2: Group by Product Family
Next, modify the merge field that represents the Product Family. Add the parameter to group on that field and to skip a row between Product Family values to make room for a subtotal (in a subsequent step).
Sort your report by the same field you are using as a group. For example, sort the example report by Product Family.
Using the SUBTOTAL9 function as depicted above will ensure each group maintains a subtotal and will prevent blank lines from appearing below the merge results.
Step 3: Subtotal on Price
Next, insert a formula to subtotal on Total Price. We’ve added bold formatting to the formula to emphasize it.
Notice each subtotal in bold text.
Step 4: Compute Grand Total
Finally, insert a formula to find the grand total of the Price column. Do not use the =SUM function to add this column, as it will include the subtotal values in the result. Instead, we’ll include the Excel formula:
We’ve also added a label for the total (“Grand Total”) and formatted the values as currency (USD).