Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

11.05 Sub-Groups

Adding additional grouping fields for either the rows or columns creates a sub-group format. This is very similar to a standard report that uses multiple groups. The first field becomes the outermost group and the remaining fields are grouped based upon the subset of data. If you preview the report and find that the fields are not in the proper order, you can rearrange them by opening the Cross-tab Expert again and using the mouse to drag and drop the fields to the correct position in the list.

Figure 11-5 shows a cross-tab object in design mode that has two grouping fields in the row and two summary fields.



Figure 11-5. The cross-tab object using multiple fields.

The large, left-most block in the cross-tab object represents the outer-most group. The innermost group is represented by the two thinner blocks just to the right of it. Both groups have a subtotal field associated with them. This is similar to a standard multi-group report because when it prints there will be a group footer showing the subtotal for the group. The two summary fields are visually represented by the multiple fields filled with the number five. The top-most field is the first summary field that was added to the Summary Fields window. Running the report generates the output shown in Figure 11-6.



Figure 11-6. The output of the cross-tab report using multiple fields.

There is no way to make a cross-tab object print the summary fields side by side. Each value is always stacked one on top of the other. You can get around this limitation by creating a duplicate cross-tab object, modifying its summary function, and then aligning it to be on top of the other cross-tab object. This gives the illusion of a single cross-tab object with multiple summary columns.

Follow these instructions to generate this type of output. Create a cross-tab object that is formatted exactly the way you want it. Make sure that the column widths are wide enough to support printing two fields side by side. Get this right the first time because if you later have to go back and reformat the cross-tab it will be much harder. Copy and paste the cross-tab object to the same section of the report. Modify the summary function to be the new calculation. Suppress all the fields except the summary fields and turn off all the grid lines. Left justify the summary field in one of the cross-tab objects and right justify the other summary field. This prevents the data from overlapping. Align the two cross-tab objects so that one is on top of the other. If all the steps were followed properly, you should not be able to tell that there are two objects on your report. You are now ready to print the report. A sample report is shown in Figure 11-7.



Figure 11-7. Output of printing summaries next to each other.