<< Click to Display Table of Contents >> Navigation: Reports > Creating and Editing Report Layouts > Groups Tab |
The Groups Tab of the Report Setup allows you to control totalling and sub-totalling in reports. While any report can be made to give a grand total for columns containing a numeric field (such as Donation Amount), grouping allows you to get totals "along the way" before the end of the report. It allows you to break the body of the report up into meaningful groups and get totals for those groups, with their totals going into the grand totals on the last page of the report. Grouping is optional, and only reports which need subtotals make use of them. For most reports, you would just leave the options of the Groups tab blank.
A good example of a grouping report is the, "Donations - Donation Detail Report With Addresses." This is a donation-based report, so it focuses on the Donations table, and must be run either directly from the donations table, or from a selection result based on it. But the report also includes biographical information - the donor's name and address. So it makes sense to group the donations of the report by the donors they belong to. That way all the donations for a particular donor appear together (instead of being scattered at random), and best of all we can get subtotals of total giving by donor for all the donations included in the report. Here is what the report looks like:
And here is the grouping setup for the report:
The Giving Entity is the donor's first and last name for individual donors, and the organization name for corporate donors. The use of the ID Number in the grouping expression guarantees a unique key for each donor account. This takes care of the case of there being, for example, donations for two John Smith's in the report. If not for the ID Number being included, there would be nothing to distinguish between the two Smiths and their donations would appear together and get sub-totalled together.
DonorQuest actually supports two levels of grouping. Let's say that in addition to grouping donations by the donors to which they belong, we also want to get sub-sub-totals by year for the donations belonging to each donor. The pre-defined report which comes with DonorQuest titled, "Donations - Donation Detail Report, Subtotals by Calendar Year" handles this with ease. Here's what the report looks like:
Notice how for the corporate donor "1984 Productions", the donation history is sub-totaled by calendar year -- showing $750 for the two donations in 2019. This is the grouping setup for this report:
The secondary grouping factor is what accomplished the subgrouping and totaling by calendar year. It made use of three DonorQuest functions - Year() to extract the 4-digit year from the Donation Date, Str() to convert that numeric year to a character value, and finally Descend() to arrange for the donations to be in descending order by year for each donor. The extensive library of functions available in DonorQuest extend its power considerably, and they are all documented in the topic on DonorQuest functions.
And now for a formal definition of each Grouping option:
Primary Grouping
The primary grouping is a character expression which is evaluated for every record in the report. Records are ordered by the evaluation of the Primary Grouping, so that records which should be in the same group will occur consecutively as the report prints. When DonorQuest detects that the primary grouping value will be different for the next record, it prints totals for all columns designated for totaling, resets it's internal group totals to zero, and begins the next group.
Primary Group Heading
The primary group heading is optional. Notice the, "Donations - Donation Detail Report With Addresses" report shown above did not use a group heading, because the information defining each group (the donor name) was already included in the body of the report. An example of a predefined report which does using the Group heading feature is the, "Donations - Grouped By Calendar Year" report. If you click on the Setup button for this report and look at the Groups tab, you will see "Year: " in the primary group heading, and if you preview the report, you will see where DonorQuest prints "Year: " followed by the actual year for the group.
Secondary Grouping
The secondary grouping behaves just like the primary, except that it does its work within the confines of the current primary grouping as a report unfolds. The predefined report titled, "Donations - Donation Detail Report, Subtotals by Calendar Year", shown above, illustrates how this works.
Secondary Group Heading
As with the Primary group heading, the secondary group heading is optional. It will not affect the functioning of the groupings. It is purely informational in nature, showing the grouping keys as they change. If the body of your report has columns which include the secondary grouping key, then you don't need it to be printed again. The "Donations - Donation Detail Report, Subtotals by Calendar Year" report shown above is a good example. The secondary grouping for it is the year of the donation date. But since the donation date is already showing in the body of the report, there is no need to print the year again (which is what the secondary grouping for that report is based on).
Summary Report Only
If this option is enabled, then only the totals and subtotals for the report will be shown, without the transaction detail from which the totals are derived.
Print Summary In Columns
This option may only be used when Summary Report Only is enabled, and the report only has one grouping level (no sub-grouping). When enabled, it will print totals in the data columns designated for totaling. For example, the predefined reports, "Donations - Grouped By State" and "Donations - Grouped By State - Summary" show the same totals, except the later has the Summary Report Only and Print Summary In Columns options turned on and omits the donation detail for the totals.
Page Eject After Group
Turn this option on if you would like each group to begin on a new page.
Grouping Is Header-Based
When the report is based on one of the tables for which a donor may have many records (such as the donation table), but the grouping is based on a field in the Header table, this checkbox should be set on. This will prevent the header field information included in the report from printing more than once for each donor.