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:
Figure 10.6. Design with cross-tab and text field in improper location.
Figure 10.7. Preview of the cross-tab and text field as requested.
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:
Figure 10.8. The Edit Summary dialog.
Figure 10.9. Percentages by country.
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:
Figure 10.10. Horizontal placement of summaries.
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:
Figure 10.11. Cross-tab with both labels changed.
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.
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.
Figure 10.13. Display String formatting formula.
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.
Figure 10.14. $0 changed to NONE by using the Display String feature.
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.