< Previous | Next >

Grouping data in a report

In this lesson, you modify your report to add grouping and sorting to organize the column information. You sort and group the column information by table, and within each table group you sort and group the column name by data type. For each data type, the column names are sorted alphabetically.

To group data in a report:

  1. If the report design is closed, double-click the MyTest.rptdesign file in the Navigator view. The report opens in the Report Editor view.
  2. Open the Layout tab at the bottom of the Report Editor view to view the report layout.
  3. Select the table:
    1. Hover over the table. The table handle appears: table handle.
    2. Click the table handle. The guide cells appear. The guide cells for the rows display at the left of the table. The guide cells for the columns display at the top of the table.
  4. Group the table detail rows by the column data type:
    1. Right-click the detail row guide cell (Guide cell) and click Insert Group. The guide cell is to the left of the detail row, as shown in the following image:
      Insert Group menu item
      The New Group window opens.
    2. Complete the New Group window as described in the following table:
      Field Setting
      Name Type GroupByType.
      Group On Select Data Type from the list of options.
      The New Group window should look like the following image:
      New Group window
    3. Click OK.
  5. Create a nested group element that groups the detail row by the source table name:
    1. Hover over the table. The table handle appears.
    2. Click the table handle. The guide cells appear.
    3. Right-click the guide cell for the detail row and select Insert Group. The New Group window opens.
    4. Complete the New Group window as described in the following table:
      Field Setting
      Name Type GroupByTable.
      Group On Select Source Table.
    5. Click OK to insert the group into the table.
    The table contains two groups. The group named GroupByType is the outer group. The outer group has a guide cell label 1. The group named GroupByTable is the inner group. The inner group has a guide cell label 2
    Table with two group elements
  6. Change the order of the grouping that occurs in the table:
    1. Open the Outline view.
    2. Expand the Body > Table - Columns > Groups node and select the Table Group - GroupByTable element.
    3. Drag the Table Group - GroupByTable element so that the element is above Table Group - GroupByType.

      When you drag the group element, a guide line appears that shows you where you can drop the element in the outline hierarchy.

    The group elements are rearranged in the Outline view, as shown in the following image:
    Outline view with two table group elements

    In the Report Editor Layout page, the order of the groups also changes.

    The GroupByTable group is the outer group, and the GroupByType group is the inner group. When the report is generated, the information in the table is grouped by source table name. Within each table name grouping, the information is grouped by data type.

  7. Format the elements of the report by using the steps in the following table:
    Element to format Steps to take
    [Name] data element
    1. In the Report Editor, select the [Name] data element. The properties of the [Name] element display in the Property Editor view.
    2. In the Properties tab of the Property Editor view, open the Padding tab.
    3. In the Left field, type 40.
    [Data Type] data element
    1. In the Report Editor, select the [Data Type] data element.
    2. In the Properties tab of the Property Editor view, open the Padding tab.
    3. In the Left field, type 20.
    [Source Table] data element
    1. In the Report Editor, select the [Source Table] data element.
    2. Select the General tab in the Property Editor view, then change the color to Blue.
    The report design should look like the following image:
    Formatted group report in the Layout page of the Report Editor
  8. Create a header row and labels:
    1. Create a new header row.

      Select the guide cell for the table header row that contains the Data Type data element and right-click and select Insert > Row > Below.

      .
      Menu to insert a row into a table
    2. In the Report Editor, move the Name and Data Type labels from first header row to the new header row that you created.

      Drag the Name label to the left column and the Data Type label to the right column.

    3. Format the Name and Data Type labels.

      Select the Name label in the Report Editor to view its properties. In the General tab of the Properties view, change the text format to Bold. In the Padding tab, change the value of Left padding to 40. For the Data Type label, change the text format to Bold, but do not change the padding.

    4. Delete the empty first header row. Select the guide cell for first header row. Right-click the guide cell, then click Delete.

    In the Layout page of the Report Editor, the report design looks like the following image:

    Formatted group report in the layout window

  9. Select the Preview tab in the Report Editor to preview your report and test the column sorting and grouping. The preview of the report is displayed. The report lists the column information grouped by table with the table names in blue text. For each database table, the column names are grouped by data type.

    The preview should look like the following image:

    Formatted group report in the preview window

You grouped the column names in the report by name and data type. The elements in the report are sorted by the type of data, providing a clearer view of the columns that are in the GOSALES schema.
When you run the report design, the report lists column information sorted and grouped correctly. You can further refine your report to nest a second table within this table. The information that is contained in the new table will depend upon the outer table. You will do this task in the next lesson.
< Previous | Next >

Feedback