With the crosstab wizard, it is easy to create crosstabs in a report, however the wizard varies with the data resource type used to create the crosstab: business view or query resource.
A web report and library component can only use business views as the data resource. For a page report it can be created either based on query resources or business views, which is determined at the time when the page report is created by the Create Using Business View option. Once defined, all the data components in the page report can only be created on the specified data resource type.
A crosstab can be inserted in the report areas listed in Component placement.
The Create Crosstab wizard appears.
From the Resources box, add the required group objects or dynamic formulas used as Group to be displayed as group fields on the columns and rows of the crosstab. To add a group field, select an object in the Resources box and click or
beside the Columns or Rows box, or drag and drop it from the Resources box to the target box. If a field is not required, select it and click
or drag and drop it to the Resources box. For the added fields, you can specify their display names in the Label column which will label the rows and columns (by default the Label column is blank and no label will be created for the rows and columns), the background color in the Color column, set the sorting manner of the field values by clicking
, and adjust their display order by clicking
or
.
Add the aggregation objects, detail objects, or dynamic resources (including dynamic formulas used as Detail or Aggregation and dynamic aggregations) as aggregate fields to the Summaries box to summarize data in the crosstab. To add an aggregate field, select an object in the Resources box and click or drag and drop to the Summaries box. When a detail object is added, you need to specify the aggregate functions for it in the Aggregate column. Edit the display names of the fields in the Label column to label the summaries, and adjust their display order by clicking
or
. If necessary, click the Comparison Function button to set the comparison function for the aggregate fields.
If you have specified to insert the crosstab into a banded object, by default the crosstab will inherit its parent's style. If you want to apply another style to the crosstab, uncheck the Inherit Style option and then select the required style from the Style box. For more information, see Inheriting Styles.
If you have specified to insert the crosstab in the report body or tabular cell, the crosstab will be inserted there upon clicking the Finish button; otherwise, you need to click the mouse button in the destination once again in order to insert the crosstab there.
If you want to use an existing dataset in the current page report to create the crosstab, click the More Options button and then:
In the Columns box, add the fields as group fields to be displayed on the columns of the crosstab. To add a field, select it in the Resources box and click or drag and drop it from the Resources box to the Columns box. If you want to display compound column groups in the crosstab, click
at the right bottom corner of the Columns box to create the column groups, then select each column group and add the required fields to it. For the added fields, you can specify their display names in the Label column which will label the columns (by default the Label column is blank and no label will be created for the columns), modify their background color in the Color column, set the sorting manner of the field values by clicking
, adjust their display order by clicking
or
, and remove an unwanted field by selecting it and clicking
or dragging and dropping it to the Resources box. When there are compound column groups, you can also select a column group and click
or
to change the group order, or click
or drag and drop it to the Resources box to remove it.
In the Rows box, add the row fields of the crosstab using the same way for adding column fields. You can also create compound row groups.
In the Summaries box, add the fields as aggregate fields to summarize data in the crosstab using either or by dragging and dropping. You can also create crosstab formulas and add them as aggregate fields so as to apply custom aggregate functions in the crosstab. If you have created compound column and row groups in the crosstab, you can add aggregate fields for each combination of the compound groups by selecting a row/column group and a column/row group and then adding the required fields. For the added aggregate fields, you can modify their aggregate functions, edit the display names in the Label column to label the summaries, adjust their display order by clicking
or
, and when an aggregate field is not required, you can select it and click
or drag and drop it to the Resources box to remove it. If necessary you can define Comparison Function for the added aggregate fields.
When you have specified to insert the crosstab into a banded object, by default the crosstab will inherit its parent's style. If you want to apply another style to the crosstab, uncheck the Inherit Style option and then select the required style from the Style box. For more information, see Inheriting Styles.
If you have specified to insert the crosstab in the report body or tabular cell, the crosstab will be inserted there upon clicking the Finish button; otherwise, you need to click the mouse button in the destination once again in order to insert the crosstab there.
Besides using the wizard, you can also drag a blank crosstab to a page report that is created using query resources. To do this:
When the crosstab is inserted into a banded object, you can set up data container link between the crosstab and its parent.
See an example: The SampleComponents catalog, included with JReport Designer, contains reports that have examples of report component types. For the crosstab component example, open <install_root>\Demo\Reports\SampleComponents\Crosstab.cls
.