BackPrevious Topic  Next TopicNext

Inserting Crosstabs in a Report

You can create crosstabs in a report easily using the crosstab wizard, however, the wizard varies with the data resource type used for the crosstab: business view or query resource. This topic introduces how you can create a crosstab with the crosstab wizard using different data resource.

You can insert crosstabs in the report areas listed in Component Placement. When you insert a crosstab into a banded object in a page report, you can use a data container link to define the relationship between the crosstab and its parent.

Note icon A page report can use either query resources or business views, which is determined by the Create Using Business View option at the time when you create the page report. Once defined, all the data components in the page report can only use the specified data resource type.

This topic contains the following sections:

Creating a Crosstab Based on a Business View

  1. Position the mouse pointer at the destination where you want to insert the crosstab.
  2. Do one of the following:
    • From the Components panel, drag the Crosstab icon Crosstab icon in the Grid category to the report.
    • Select Insert > Crosstab.
    • Select Home > Insert > Crosstab.

    Designer displays the Create Crosstab dialog box, which contains a set of screens for helping you define a crosstab easily. You can use the Back and Next buttons or select the screen name on the screen navigation bar to switch between the screens.

  3. In the Data screen, select the business view in the current catalog using which to create the crosstab.

    If you have specified to insert the crosstab into any of the following panels in a banded object: banded header panel, banded footer panel, group header panel, or group footer panel, Designer displays the Inherit from the Parent option. Select it if you want the crosstab to inherit the business view that its parent banded object uses.

    Create Crosstab - Data

  4. In the Display screen, specify the fields to display in the crosstab. You can specify a title for the crosstab in the Title text box.

    Create Crosstab - Display

    The Resources box lists the view elements in the specified business view and the dynamic formulas and aggregations that you have created for the business view in the current report. You can use these objects to create the crosstab.

    • In the Columns and Rows boxes, add group objects Group icon or dynamic formulas used as Group Dynamic Formula as Group icon as the column/row fields to display on the column and row headers of the crosstab. You can add an object using either the arrow button beside the target box or by dragging it from the Resources box to the target box.

      For each column/row field, you can double-click in the Label text box and type a name to label the corresponding column/row header, or select Auto Map Field Name in the text box if you want to automatically map the label text to the dynamic display name of the field at runtime (the Label text box is blank by default so the crosstab shows no label for the column/row header); double-click in the Color text box to specify its background color (to make the color take effect, you need to edit the Background property of the field to "Transparent" in the Report Inspector after you finish creating the crosstab); select Sort Sort button to change the sort manner of its values between Ascend, Descend, and No Sort. To adjust the display order of the column/row fields on the column/row headers, select a field and select Move Up Move Up button or Move Down Move Down button; to delete an unwanted column/row field, select it and select Remove Trash Can button or drag it to the Resources box.

    • In the Summaries box, add aggregation objects Aggregation cion, detail objects Detail icon, dynamic formulas used as Aggregation Dynamic Formula as Aggregation icon, dynamic formulas used as Detail Dynamic Formula as Detail icon, or dynamic aggregations Aggregation cion as aggregate fields to create aggregations in the crosstab. You can add an object by either selecting Add Add Aggregation button or dragging it from the Resources box to the Summaries box. When you add a detail object as the aggregate field, double-click in the Aggregate text box to specify the aggregate function for it. If you select DistinctSum, you should select the ellipsis Ellipsis button in the Distinct On text box to specify one or more fields according to whose unique values to calculate DistinctSum using the Select Fields dialog box.

      For each aggregate field, you can double-click in the Label text box and type a name to label the corresponding aggregations in the crosstab, or select Auto Map Field Name in the text box if you want to automatically map the label text to the dynamic display name of the field at runtime (the Label text box is blank by default so the crosstab shows no label for the aggregations); select Comparison Function to define a comparison function for it. To adjust the display order of the aggregate fields, select a field and select Move Up Move Up button or Move Down Move Down button; to delete an unwanted aggregate field, select it and select Remove Trash Can button or drag it to the Resources box.

      An aggregate field can generate detail aggregations, aggregations for subtotals, and aggregations for grand totals for each combination of the column and row fields.

  5. In the Filter screen, apply a filter to reduce the data to display in the crosstab. You can select a predefined filter of the specified business view from the Filter drop-down list to apply, or select User Defined in the list to define a new filter as required.

    Create Crosstab - Filter

  6. In the Layout screen, specify the layout properties of the crosstab.

    Create Crosstab - Layout

  7. In the Style screen, specify the style of the crosstab.

    If you have specified to insert the crosstab into a banded object, the crosstab inherits its parent's style by default; to apply another style to the crosstab, clear Inherit Style and select the required style from the Style box.

    Create Crosstab - Style

  8. Select Finish to insert the crosstab in the report.

    If you have selected a panel in a banded object as the crosstab destination, after finishing the dialog box, you need to select in the destination once again in order to insert the crosstab there.

Back to top

Creating a Crosstab Based on a Query Resource

Using query resources, you can create compound crosstabs. A compound crosstab contains multiple crosstabs that are mashed up together in a flexible way. You can create aggregations based on any combinations of the row and column compound groups, making more complex analysis possible.

  1. Position the mouse pointer at the destination where you want to insert the crosstab.
  2. Select Insert > Crosstab or Home > Insert > Crosstab.

    Designer displays the Create Crosstab dialog box, which contains a set of screens for helping you define a crosstab easily. You can use the Back and Next buttons or select the screen name on the screen navigation bar to switch between the screens.

  3. In the Data screen, select the data resource in the current catalog using which to create the crosstab.

    Create Crosstab - Data

    If the predefined data resources are not what you want, you can select the first item in the corresponding resource node to create one in the current catalog to use. When you select a query, you can select Edit to modify the query. Designer then automatically creates a dataset based on the selected data resource in the page report.

    If you want to use an existing dataset in the current page report to create the crosstab, select More Options and then:

    • Select Existing Dataset and select a dataset. You can select Edit to modify the specified dataset in the Dataset Editor dialog box, or select <New Dataset...> to create a dataset in the page report to use. It is always better to use an existing dataset rather than create a new one. Even when the two datasets are based on the same query, Logi Report Engine still runs the query separately for each dataset.
    • If you have specified to insert the crosstab into any of the following panels in a banded object: banded header panel, banded footer panel, group header panel, or group footer panel, Designer enables the Current Dataset radio button. Select it if you want the crosstab to inherit the dataset from its parent banded object.
  4. In the Display screen, specify the fields you want to display in the crosstab.

    Create Crosstab - Display

    The Resources box lists the DBFields in the specified data resource, and the formulas that are valid to these DBFields in the current catalog. You can create the crosstab using these fields. If the predefined formulas cannot meet your requirement, you can select <New Formula...> in the Formulas node to create the formulas you want.

    • In the Columns and Rows boxes, add column/row fields to display on the column and row headers of the crosstab. To add a column/row field, select a DBField or formula in the Resources box and select the arrow button beside the target box, or drag it from the Resources box to the target box. If you want to display compound column/row groups in the crosstab, select Add Compound Group at the right bottom corner of the Columns/Rows box to create them, then select each compound group and add the required fields to it.

      For each column/row field, you can double-click in the Label text box and type a name to label the corresponding column/row header (the Label text box is blank by default so the crosstab shows no label for the column/row header); double-click in the Color text box to specify its background color (to make the color take effect, you need to edit the Background property of the field to "Transparent" in the Report Inspector after you finish creating the crosstab); select Sort button to change the sort manner of its values between Ascend, Descend, and No Sort. To adjust the display order of the column/row fields on the column/row headers, select a field and select Move Up Move Up button or Move Down Move Down button; to delete an unwanted column/row field or compound group, select it and select Remove Trash Can button or drag it to the Resources box. You can also adjust the display order of the compound groups and delete any unwanted compound group in the same way.

    • In the Summaries box, add aggregate fields to create aggregations in the crosstab. To add an aggregate field, select a DBField or formula in the Resources box and select Add Add Aggregation button or drag the field from the Resources box to the Summaries box. You can also select <New Crosstab Formula...> in the Crosstab Formulas node to create crosstab formulas to use as the aggregate field. When you add a DBField or formula as the aggregate field, double-click in the Aggregate text box to specify the aggregate function for it. If you select DistinctSum, you should select the ellipsis Ellipsis button in the Distinct On text box to specify one or more fields according to whose unique values to calculate DistinctSum using the Select Fields dialog box. 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 each aggregate field, you can also double-click in the Label text box and type a name to label the corresponding aggregations in the crosstab (the Label text box is blank by default so the crosstab shows no label for the aggregations); select Comparison Function to define a comparison function for it. To adjust the display order of the aggregate fields, select a field and select Move Up Move Up button or Move Down Move Down button; to delete an unwanted aggregate field, select it and select Remove Trash Can button or drag it to the Resources box.

      An aggregate field can generate detail aggregations, aggregations for subtotals, and aggregations for grand totals for each combination of the column and row fields.

  5. In the Filter screen, add filter conditions based on the fields that have been added to the crosstab to reduce the data. Select here for how to define a filter.

    Create Crosstab - Filter

  6. In the Layout screen, specify the layout properties of the crosstab.

    Create Crosstab - Layout

  7. In the Style screen, specify the style of the crosstab.

    If you have specified to insert the crosstab into a banded object, the crosstab inherits its parent's style by default; to apply another style to the crosstab, clear Inherit Style and select the required style from the Style box.

    Create Crosstab - Style

  8. Select Finish to insert the crosstab.

    If you have selected a panel in a banded object as the crosstab destination, after finishing the dialog box, you need to select 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 uses query resources.

  1. From the Components panel, drag the Crosstab icon Crosstab button in the Grid category to the destination in the page report which allows the insertion of a crosstab. Designer creates a blank crosstab.
  2. In the Data panel, select the dataset in the current page report with which you want to create the crosstab from the dataset drop-down list, or select <Choose Data from...> from the list to create a new a dataset for the crosstab.
  3. Drag the required fields from the Data panel to create the column headers, row headers and aggregations in the crosstab.

Example of Creating a Compound Crosstab

  1. Make sure SampleReports.cat is the currently open catalog file. If not, select File > Open Catalog to open it from <install_root>\Demo\Reports\SampleReports.
  2. Select File > New > Page Report.
  3. In the Select Component for Page Report dialog box, select Crosstab and select OK. Designer displays the Crosstab Wizard dialog box.
  4. In the Data screen, select the query WorldWideSales in Data Source 1 of the catalog.
  5. In the Display screen, select Add Compound Group Add button in the Rows box and Designer adds two compound row groups in the box.

    Add Compound Row Groups

  6. Select Row Compound Group, drag the formula year and the field Category from the Resources box to the compound row group one by one, double-click in the Label text box of each field and type Year and Category to label the row headers.
  7. Select Row Compound Group 1 and add the field Country to it and edit its label to Country.

    Add Fields to Compound Row Groups

  8. Select Add Compound Group Add button in the Columns box, then add the formula Quarter to Column Compound Group and the field Order ID to Column Compound Group 1, specify their labels as Quarter and Order ID.
  9. Select Row Compound Group in the Rows box and Column Compound Group in the Columns box, drag the field Quantity from the Resources box to the Summaries box as the aggregate field of the compound groups. Double-click in the Aggregate text box and select Sum from the drop-down list, then double-click in the Label text box and type Quantity to label the aggregations.

    Add Aggreagate Field to Compound Groups

  10. Repeat the above step to add the following fields with the specified aggregate functions as the aggregate fields for the combinations of the following compound groups. Use the fields' display names as the labels.
    • Row Compound Group and Column Compound Group 1: Price, Average
    • Row Compound Group 1 and Column Compound Group: Cost, Sum
    • Row Compound Group 1 and Column Compound Group 1: Unit Price, Average
  11. Switch to the Filter screen and specify the filter conditions.

    Specify Filter Conditions

  12. Select Finish to create the crosstab.
  13. In the Report Inspector, select Label, Label 1, QUARTER, Label 4, Label 5, YEAR, Label 6, Label 7, CATEGORY, Label 10, Label 11, Label 12, QUANTITY, QUANTITY 1, QUANTITY 2, QUANTITY 3, QUANTITY 4, and QUANTITY 5, specify the Background property to Lightgray.

    Set the Background Property for Objects

  14. Repeat the above step to specify the Background property of Label 2, Label 3, Order ID, Label 15, Label 16, Label 17, PRICE, PRICE 1, PRICE 2, PRICE 3, PRICE 4, and PRICE 5 to Pink; specify the Background property of Label 8, Label 9, COUNTRY, Label 13, Label 14, COST, COST 1, COST 2, and COST 3 to Orange; specify the Background property of Label 18, Label 19, UNIT PRICE, UNIT PRICE 1, UNIT PRICE 2, and UNIT PRICE 3 to Gray.
  15. Save the report.
  16. Select View > Preview As > Page Report Result to preview the report in Page Report Studio.

    You can see that the crosstab contains four parts, showing different summary information for different combinations of row compound groups and column compound groups.

    Preview the Report

Back to top

BackPrevious Topic  Next TopicNext