Using Advanced Cross-Tab Features

Crystal Reports version 9 introduced significant cross-tab improvements. The advanced features gave cross-tabs improved flexibility and functionality to satisfy even more reporting requirements.

Setting Relative Position

When it comes to planning the width or length of cross-tabs, remember they expand dynamically. With the addition of new information or data, the number of rows or columns can grow or shrink. This makes putting objects at the end of a cross-tab very difficult because it's unclear when the object will be overwritten if new data appears.

For the same issue at the bottom of a cross-tab an easy solution exists. Place the new object in the next report sectioneven if it means adding a new section. By default, objects in Crystal Reports do not overwrite a section.

However, you often need to specify an item in the far-right column. In this report you might want a logo to be displayed to the right of the cross-tab. But, in Design, the size of the cross-tab doesn't match what you see in Preview. Follow these steps to set the Relative Position:

  1. Open crosstab2.rpt. Start with your last saved document by choosing it from the File list on the File, Open menu.
     
  2. Insert a text object by opening the Insert menu, and then selecting Text Object.
     
  3. Preview the report. Click F5 to see the result. It's not exactly as you intended (see Figure 10.6).
     

    Figure 10.6. Design with cross-tab and text field in improper location.

    graphics/10fig06.jpg  
  4. Set the Relative Position property. Right-click on the Report Header label (on the left where it says Report Header, or RH, in the gray area). Choose Section Expert. Toggle the Relative Positions check box and click OK. To see the resulting report, refer to Figure 10.7.
     

    Figure 10.7. Preview of the cross-tab and text field as requested.

    graphics/10fig07.jpg  

The Relative Position property works on the left, top, and right borders of the cross-tab. Remember that the bottom border of the cross-tab is handled by the end of a section.

Relative positions can be used in many situations. For example, showing a chart on the information in the cross-tab can be very useful.

Inserting a "Percentage of" Summary

Summary values can also be displayed as percentages of either the total rows or total columns:

  1. Add another summary. Right-click in the top left of the cross-tab where no data appears and choose Cross-Tab Expert. In the Cross-Tab tab, choose to add the Order Amount to the Summarized Fields list box by clicking the arrow (>) button. Notice that it looks like it duplicates the summary above it, so choose the Change Summary button.
  2. Change the Summary to a Percentage Summary. In the Edit Summary dialog in the Options box, select Show As Percentage Summary. Notice that it has an option for Row or Column. In this case you want to know by country (row) where the percentage split is, so keep Row selected as shown in Figure 10.8.

    Figure 10.8. The Edit Summary dialog.

    graphics/10fig08.jpg

     
  3. Preview the results by clicking OK on both dialog windows. It should look like Figure 10.9.

    Figure 10.9. Percentages by country.

    graphics/10fig09.jpg  

Notice that the USA is consistently the largest percentage of Xtreme's orders. It's very easy to see this when percentages are added to the cross-tab.

Horizontal and Vertical Placement

Because the percentages add up to 100% down the page, it would be easier to understand if the summaries could be displayed side by side instead of one on top of the other. That way, the numbers down the page could be added up easily.

Crystal Reports allows the toggle between horizontal and vertical placement of summaries:

  1. Launch the Cross-Tab Expert. Right-click in the top-left of the cross-tab again and choose Cross-Tab Expert. Select the Customize Style tab. Under Summarized Fields, choose Horizontal; select the Show Labels option.
     
  2. View the report. Click the OK button to see the changes made to the cross-tab (see Figure 10.10).
     

    Figure 10.10. Horizontal placement of summaries.

    graphics/10fig10.jpg  

Inserting Summary Labels

Notice that on the report in Figure 10.10, both titles for the percentage and the summary are exactly the same (Order Amount). This is because Crystal Reports is showing the field that a summary is acting on. In this case, where the field is being acted on twice, it's not a good choice.

Crystal Reports enables you to edit these labels right on the cross-tab in both Design and Preview modes:

  1. Edit the Summary's Title. Right-click on the first Order Amount field in the cross-tab and choose Edit Text. Delete the Order Amount Text and add Sum instead. Then choose the Align Center button on the toolbar while the item is highlighted. Click off the object and see the result.
  2. Edit the Percentage Title. Repeat the previous step for the second Order Amount field, but instead of changing the text to sum, change it to %, as shown in Figure 10.11.

    Figure 10.11. Cross-tab with both labels changed.

    graphics/10fig11.jpg  

Adding a Display String

Cross-tabs are based on the need for numbers or currency to be summarized, but there are times when the numbers don't need to be seen to get the point across. Crystal Reports has a feature for all fields called Display String. This formatting feature allows a different representation for a field than its underlying value. For example, a teacher might want to see a grade letter beside a percentage mark, as shown in Figure 10.12.

Figure 10.12. Math 101 marks with letter grades as display strings.

graphics/10fig12.jpg

As previously mentioned, cross-tab cells are always an intersection of rows and columns with a summary because the strings are the visual representation of the underlying summary being computed in the cross-tab. You can affect this string using the advanced Cross-Tab features of Crystal Reports.

Crystal Reports can now separate the data value from its display. This is a powerful feature and is not limited to cross-tabs, although it plays a major role in cross-tabs because of the requirement of summaries.

To complete this report, ensure that all $0.00 amounts be shown as NONE on the report.

  1. Format the Order Amount Summary. Right-click on one of the $0.00 amounts on the report and choose Format Field. Choose the Common tab and then choose the Conditional Formatting (x+2) button to the right of Display String. The Formula Workshop appears.
     
  2. Format Formula for strings. Use an If-Then-Else formula structure to accomplish the task. The final result is If CurrentFieldValue = 0 Then "NONE" Else ToText(CurrentFieldvalue) (see Figure 10.13).
     

    Figure 10.13. Display String formatting formula.

    graphics/10fig13.jpg  

    TIP

    Try to avoid using explicit field names in these formulas so that they can be reused in other places.

    Also, remember that these are string formulas. That's why the ToText is needed around the CurrentFieldValue. Both Then and Else clauses must contain similar data types.

  3. Close the dialog windows. Choose the Save and Close button on the Formula Workshop and then click OK on the Formatting dialog. The result is shown in Figure 10.14.
     

    Figure 10.14. $0 changed to NONE by using the Display String feature.

    graphics/10fig14.jpg  
  4. Save the report as Crosstab3.rpt by choosing File, Save As.
     

TIP

The same technique that you used to change the display value of the cell can be used on any area, and you can combine the interactivity provided by parameters and other formula functions to drive any section or field in the cross-tab.


Crystal Reports in the Real WorldAdvanced Cross Tabs

Although a single Cross-Tab that covers all the data in a report can be quite useful, with some large datasets it can be quite unreadable. A simple solution to this is to group the report and place the cross-tab in the group header or footer. Cross-tabs are context sensitive and if placed in a group header or footer will show only data for that group.

  1. Using the skills described in earlier chapters, create a new report from the Xtreme Sample Database. Add the Customer table to the report, group the report by country, and remove all fields but the Country field in the group header. See Figure 10.15 for a visual of the report's starting point.
     

    Figure 10.15. Report framework.

    graphics/10fig15.jpg  
  2. From the Report menu, choose Cross-Tab. From the list of available fields, select Customer Name and add it to the Rows window of the Cross-Tab. Select the Region and add it to the Columns window. Select Last Year's Sales and add it to the Summarized Fields window. Check your work against Figure 10.16 for accuracy.
     

    Figure 10.16. Building the cross-tab.

    graphics/10fig16.jpg  
  3. Click OK to close the Cross-Tab expert. Add the cross-tab to the group header and preview the report. In Figure 10.17, the completed report can be seen.
     

    Figure 10.17. Grouped cross-tabs can avoid confusion through improved readability.

    graphics/10fig17.jpg  
  4. Save the report as GroupedCrossTab.rpt.
     

Part I. Crystal Reports Design

Creating and Designing Basic Reports

Selecting and Grouping Data

Filtering, Sorting, and Summarizing Data

Understanding and Implementing Formulas

Implementing Parameters for Dynamic Reporting

Part II. Formatting Crystal Reports

Fundamentals of Report Formatting

Working with Report Sections

Visualizing Your Data with Charts and Maps

Custom Formatting Techniques

Part III. Advanced Crystal Reports Design

Using Cross-Tabs for Summarized Reporting

Using Record Selections and Alerts for Interactive Reporting

Using Subreports and Multi-Pass Reporting

Using Formulas and Custom Functions

Designing Effective Report Templates

Additional Data Sources for Crystal Reports

Multidimensional Reporting Against OLAP Data with Crystal Reports

Part IV. Enterprise Report Design Analytic, Web-based, and Excel Report Design

Introduction to Crystal Repository

Crystal Reports Semantic Layer Business Views

Creating Crystal Analysis Reports

Advanced Crystal Analysis Report Design

Ad-Hoc Application and Excel Plug-in for Ad-Hoc and Analytic Reporting

Part V. Web Report Distribution Using Crystal Enterprise

Introduction to Crystal Enterprise

Using Crystal Enterprise with Web Desktop

Crystal Enterprise Architecture

Planning Considerations When Deploying Crystal Enterprise

Deploying Crystal Enterprise in a Complex Network Environment

Administering and Configuring Crystal Enterprise

Part VI. Customized Report Distribution Using Crystal Reports Components

Java Reporting Components

Crystal Reports .NET Components

COM Reporting Components

Part VII. Customized Report Distribution Using Crystal Enterprise Embedded Edition

Introduction to Crystal Enterprise Embedded Edition

Crystal Enterprise Viewing Reports

Crystal Enterprise Embedded Report Modification and Creation

Part VIII. Customized Report Distribution Using Crystal Enterprise Professional

Introduction to the Crystal Enterprise Professional Object Model

Creating Enterprise Reports Applications with Crystal Enterprise Part I

Creating Enterprise Reporting Applications with Crystal Enterprise Part II

Appendix A. Using Sql Queries In Crystal Reports

Creating Enterprise Reporting Applications with Crystal Enterprise Part II



Special Edition Using Crystal Reports 10
Special Edition Using Crystal Reports 10
ISBN: 0789731134
EAN: 2147483647
Year: 2003
Pages: 341

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