Using Top N with Cross-Tabs Reports


Group sorts can be done on a report level so that the records are sorted and removed as necessary. However, there are times when the records are needed in the overall report but not in a cross-tab.

1.

Right-click in the top-left corner of the cross-tab where there is no data or words and choose Group Sort Expert. Choose Top N for the primary list box and change 5 to 10 in the Where N Is field. In this example, make sure that the Others option is not selected.

2.

Click OK in the Group Sort Expert to view the final result, as shown in Figure 10.5.

Figure 10.5. Cross-tab with a Top 10 Group Sort applied.


3.

Save your work by choosing File, Save As. Call this cross-tab2.rpt and then click OK.

4.

What would happen if there was a need to have the option of showing the Top 5, the Top 10, or some other value for N? In previous versions of Crystal Reports, N was hard coded; if this level of flexibility was needed, there would be quite a bit of work involved! New in Crystal Reports XI, however, a formula may be used to set the value of Nand where there is a formula, there can be a parameter. Using the skills you learned in Chapter 5, "Implementing Parameters for Dynamic Reporting," create a parameter.

5.

To create a new parameter, open the Field Explorer, select Parameter Fields, and click the New button. For Name, call this Top N, and set the type to Number. Because you've already learned about parameters, simply click OK to move on.

6.

Right-click on your cross-tab in the top left where there are no numbers or text, and select Group-Sort Expert. To the right of the number 10, click the Formula button. When the window opens, simply double-click the parameter in the list of fields. Figure 10.6 shows what the formula should look like.

Figure 10.6. Setting the parameter to be the value for N makes this chart much more flexible.


7.

Refresh the report several times using different values for N. Save this report as cross-tab dynamic N.rpt.




Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net