|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports Basics: Cross-Tab AnalysisThis is based on the book, Crystal Reports: A Beginner’s Guide. For more detail and explanation, plus practice exercises, order the book here. Cross-tabs are special objects you can place in your Crystal Reports. If you know what a datasheet (spreadsheet or Access datasheet view) looks like, you know what a cross-tab looks like. It’s a cross tabulation created by rows and columns. Often, a cross-tab is the meat of the report. It doesn’t have to be, but you can use it that way. People are using to seeing rows and columns, so this is often an appropriate way to display information. Keep in mind, a cross-tab is not a spreadsheet—it’s database-driven. Thus, when you view it in design view, you’ll see the layout—rows and columns—but not the data. In the preview mode, you’ll see the rows and columns full of the data you requested. And the more records your Crystal Report returns, the larger the cross-tab will be. Some facts:
Cross-tabs add functionality to Crystal Reports—the items above are merely the tip of the iceberg. For even more functionality, you can use third-party programs, such as the ones available here. Also consider cross-tab wrapping. Use a wrapping crosstab to eliminate those wide reports. Cathy Mitchisch demonstrated this at the CDUGNA conference presentation in New Orleans in May, 2004. She was took a crosstab report that spread over several pages horizontally and wrapped the crosstab so it appeared on one page. It takes a little bit of preparation, but looks great. Think of it as a crosstab relay. The data must arrive in the report already summarized and sorted. We used a SQL command to preprocess the data:
With one record for each cell, we could now use a WhileReadingRecords formula to accumulate a record counter in the report. We called this formula {@EachRegion}
We then created a formula to use as a group for each wrap of the crosstab {@GroupRegions}.
We created a group on this formula. The 6 refers to the six regions that appear in each group. You need to subtract 1 of the RegNo variable because the first region is region 1, and if you don’t do that you get five regions in the first group and six in the rest. We then created a crosstab and placed it in the group header. The Crosstab has a Row field of Country, a column field of Region and a Summarized field of LYSales (Sum). If you want this to work for multiple countries, you will need the crosstab in a subreport and you then process the subreport for one country at a time.
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |