Crystal Reports has advanced grouping tools that allow you to group on values not directly represented in your data. Specified Order Grouping is one such tool. The following examples illustrate when you could use specified grouping to create custom groups.
- The report does not contain the field on which you want to group. For example, the report contains a City field and a State field but no Country field; you want to group by country.
- The report may contain the field you want to group on, but you are not satisfied with the grouping based on the values in that field. For example, you have a constituency code on the report that includes specific constituencies (Current Parent, Past Parent, Future Parent, Board Emeritus, Board Member, Board Committee, etc.) but you want all Parents to appear as a single group and all Board Members to appear as a single group. In this case you may build custom groups and manually assign the records you want to be in each group.
- The report may contain the field you want to group on, but you want to select specific values or ranges of values for each group. For example, you might want one group to contain records where the Total Amount is less than a certain value, a second group where the Total Amount falls between two values, and a final group where Total Amount is greater than a certain value. In this case, you can build your groups using the same range of selection facilities you use to create record selection queries.
Note: In this example, Total Amount refers to The Raiser's Edge for Windows field, and not a summary field created in Crystal Reports
Specified order grouping provides a solution to these custom sorting and grouping challenges. To create a custom grouping using specified order grouping:
- Select Insert, Group from the menu bar and select in specified order as the sort option on the Common tab.
- On the Specified Order tab, set up the custom groups, indicating the specified order of your grouping.
Note: A record can be assigned to only one group
- To create the specified order group, click New.
- On the Define Named Group screen, specify the group name and the record selection criteria constituting the specified group. This functions like the Select Records Expert.
On the example screen above, the group is called Parents and consists of constituents with one of the following constituency codes: Grandparent, Former Parent, Current Parent, and Duplicate Parent.
- Repeat this step for each group you need to create.
- Once you create a custom group, the Others tab appears. On this tab, specify what to do with all the remaining records that do not meet any of the selection criteria of the custom groups.
By default, they will be included in a group called others. The other options are:
Discard all others, which removes the records and does not show them on the report.
Leave in their own groups, which groups all remaining records based on the group criteria. For example, if Alumnus did not fall into the Parents group or the Board Member group, all records for Alumnus are put into an Alumnus group.
Following is an example of a report using specified order grouping to group all constituents in the Parents group or the Board Member group based on their constituency code. Constituents in the Parents group have one of the following constituency codes: Current Parent, Former Parent, and Duplicate Parent. Constituents in the Board Member group have a constituency code of either Board Member or Trustee.
Note: Grand totals show the grand totals for all records selected by the Select Records Expert, not only for those on the report after specified groups.
Jonathon P. Smith Current Parent Louis A. Bennett Former Parent Samantha A. Young Current Parent Dorothy A. Thomas Current Parent John Lanning Current Parent Mary E. Simpson Duplicate Parent Steven Light Duplicate Parent
Mary M. Reynolds Board Member Myron Banks Board Member Tom Mathews Trustee