### Creating a crosstab report

Assume that you have already opened a page report, to create a crosstab report within it:

1. Do either of the following:
   - Click File > New > Page Report Tab on the menu bar.
   - On the report tab bar, right-click an existing report tab in the report and click Insert on the shortcut menu.
2. In the New Page Report Tab dialog, specify the title of the report tab, select the Crosstab layout and click OK. The Crosstab Wizard appears.
3. In the Data screen of the wizard, specify the dataset on which the crosstab will be built.
   - To build the crosstab on a new dataset created from the catalog resources, check the New radio button, and then select the data source of the dataset. If the given data resources are not what you want, click the <Add xxx...> item to create one. And if you choose to create the dataset from a query, you can click the Modify button to further modify the query if required.
   - To build the crosstab on an existing dataset in the report, check the Existing radio button, and then select the dataset as required (click the Modify button to modify the selected dataset in the Dataset Editor if necessary). You can also click the <Add Dataset...> item to create one as required.

   Note: When you want to create a crosstab report on a hierarchical data source, pay attention to the unique features of HDS. For details, refer to Developing reports from HDS.

4. In the Display screen, add the required fields from the Resources box to the Columns and Rows boxes respectively to make them displayed on the columns and rows of the crosstab. 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 . Then, add the fields as aggregate fields to the Summaries box, specify the aggregate functions for the added fields, and edit the display names of the fields in the Label column to label the summaries. If necessary, click the Comparison Function button to set the comparison function for the aggregate fields. You can also create some crosstab formulas and add them as aggregate fields so as to apply custom aggregate functions in the crosstab.
5. If you want to create a chart together with the crosstab in the report body, go to the Chart screen. Select the chart type you like, from the Category and Series drop-down lists, where all the fields that have been added to the columns and rows of the crosstab are listed, choose the fields to be displayed on the category (X) axis and series (Z) axis of the chart, then select the field you want to display on the value (Y) axis of the chart from the Show Values drop-down list, you can choose from all the aggregate fields in the crosstab.
6. To apply some filters to the crosstab so as to reduce data displayed in the crosstab, go to the Filter screen and define the filter conditions.
7. In the Layout screen, specify the layout of the crosstab.
8. In the Style screen, specify the style of the crosstab, and if required, click the Page Setup button to set the page settings.
9. When done, click Finish to create the report tab.

See also:

- Crosstabs for details about the crosstab component.
- An example: The SampleComponents catalog, included with JReport Designer, contains reports that have examples of report layout types. For the crosstab report layout example, open `<install_root>\Demo\Reports\SampleComponents\Crosstab.cls`.