Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Report groups

Reports used in the real-world-business are more than simple list of rows and columns. To gain information from the presented data, the report data is sorted and condensed into separate sections, which corespond to the logical structure of the report. Therefore report engines introduced the concept of groups to support the structuring of report data.

...

Groups in the reporting usually can be mapped to 'is-part-of' relations in the real world. Employees could be grouped by the department, where they work in, or by the first letter of their last name.

The Control Break Algorithm

Reporting can be a very resource intenstive process. Data has to be queried from databases and other sources, the data must be processed, sorted and intermediate results must be computed and finally the report output must be generated. Even with today's powerfull computers, performance is a key to customer satisfaction. To fullfill these performance requirements, it is unacceptable to waste time building a global view on the report data, unless absolutly necessary.

For performance reasons, group memberships are computed at runtime with an algorithm called the 'control-break algorithm'. Understanding this algorithm is the key to successful reporting, as this algorithm heavily influences how the report engine behaves and how groups are built up. The control-break-algorithm does not build a global view over all group instances. To detect the end of one and the start of a new group, it compares the current row with the previously read row of data. If the data of one of the group's key columns is different, the current group must be finished. If the report processing has not reached the last row, a new group instance is opened immediatly. This new group will remain active until either the end of the report data has been reached or the group key values changed.

Some Definitions

A group is a contigiuous set of rows, where all rows of the group share the same group key.

...

A group with a group key without attributes defined is called the default group. This group has a single instance which always spans the complete report data set.

The single level Control-Break-Algorithm as pseudo code

Code Block
OPEN file.

READ record.

PRINT ReportHeader.

WHILE NOT END-OF-FILE

DO

   VAR groupKey := GET-CURRENT-GROUP-KEY.

      PRINT GroupHeader.

   WHILE (NOT END-OF-FILE AND

             groupKey IS-EQUAL-TO GET-CURRENT-GROUP-KEY)

   DO

      PRINT ItemBand.

      READ

   DONE.

   PRINT GroupFooter.

DONE

PRINT ReportFooter.

CLOSE FILE.

...

  1. A sub group can only be opened, after its parent group has been opened.
    Subgroup processing starts as soon as the group header of the parent group has been printed. Immediatly after the processing finishes, the parent group's footer gets printed. The processing flow cannot reach the subgroup without passing through the parent group.
  2. A sub group must cease control as soon as one the parent's group attributes changes.
    A control break in one of the parent groups will close all subgroups. As soon as the parent group generated a new group instance, new instances of the sub groups will be opened as well. (In Pentaho Reporting, sub groups must contain all the group attributes of it's parent.)
  3. Adding an attribute, which has a constant value, to the group definition will not alter the number or order of the generated group instances.
    This allows you to insert artificial group levels to the report by referencing static or non-existing fields (which always evaluate to 'null') in addition to the real group fields. That little trick can be used to print more than one group header or footer.
  4. Adding an attribute, which has a constant value, to the group definition will not alter the number or order of the generated group instances.
  5. A group can only have one directly attached sub group. Building trees of groups is impossible with that algorithm.
     

Working with groups: Examples

The effects of the control break algorithm are best unterstood when looking at an example. Lets take the following table as datasource.

...