Defining Group Lines

Group lines are a special type of line. They are used to group together the data lines that are to be printed.

You can use the "Group by" line property to specify how the data is to be grouped. This means that the line is printed whenever the result of the expression changes from one data line to the next. If you don't enter an expression, the line will not be printed and the property is highlighted in red in the property window.

A group header is printed accordingly before the data line is output, e.g. "Item group XYZ" group heading.

A group footer appears after the condition of the "Group By" property has changed, in other words, after outputting the data line. Group footers are suitable e.g. for totals of data within a group.

In the report container you can also output a group sum in the group header with the Precalc() function, e.g. Precalc(Sum(Item.UnitPrice), Left$ (Item.No,1)).

Figure 5.16: Group Headers

Example: Grouping by the first letter of the "Item.No" field.

Figure 5.17: Group lines in an article list

1.  Create a new line definition on the "Group header" tab. Enter the following expression for the content of the column:

"Main group: ' + Left$ (Item.No,1)"

The result of the expression "Left$ (Item.No,1)" is the first character of the "Item.No" variable. Whenever the first letter of "Item.No" changes, the text "Main group: " and the first letter in each case will be printed.

2.  Enter "Left$ (Item.No,1)" as the condition for the "Group By" property.

With each new first letter, a corresponding intermediate header will be printed in the list.

3.  Multiple line layouts are possible with group headers as well. In this way, you can produce hierarchically structured intermediate headers. For example, you can define a line layout that is produced, as in the above example, based on the first letter of the "Item.No" variable. In addition, you define a second line layout that produces intermediate headers based on the first three characters of "Item.No".

4.  Create a new line grouping for the sub-group header in the same way. Enter "Left$ (Item.No,3)" as the condition for the "Group By" property.

Enter the "sub-group" for the content of the column: ' + Left$ (Artikel.Nr,3)": When the first 3 letters change, a corresponding intermediate header will be printed in the list.

Along with the properties of the "normal" lines, you also have the following at your disposal:

▪    Group sums: You can set sum variables to 0 here once they have been output in order to produce group sums.

▪    Pagebreak before outputting a group header or break after outputting a group footer.

▪    The option of always displaying the group header additionally at the start of the table if the group has been separated by a pagebreak.

Also see chapter Overview of Properties.