Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

Aggregate Fields

A aggregate field is a pre-processor macro-field that represents a template for a summary field along with a auto-generated aggregate function for this field.

Old situation

Prior to version 0.8.11, creating group sums that should be displayed in a group or report-footer was relatively cumbersome. To make a simple sum appear, a user would have to manually add one of the Aggregate-Functions to the report, give it a proper name and configure it. Finally he had to create a date/number/text field to display the sum in the report and link this field to the previously created expression.

For reports with a large number of display-only aggregations the separation between the functions and fields leads to a maintenance nightmare, as expressions and fields must be kept in sync all the time.

Pre-Processor driven solution

With the new element-attributes and the ability to run a pre-processor on the report before the report is actually executed, we can simplify the creation of the aggregate fields.

The aggregation pre-processor processes all fields that have the 'wizard:aggregation-type' attribute declared in their meta-data description and that have the a valid value for the attribute.

Upon processing, the pre-processor generates a new Function based on the function type given in the attribute 'wizard:aggregation-type'. The function must implement the 'AggregateFunction' interface. The function's group property will be set to the design-time value of 'wizard:aggregation-group'. If the function implements the 'FieldAggregateFunction' interface, the function's 'field' property will be set to the element's 'core:field' design-time property. The name of the function will be auto-generated and will be stored in the element's 'core:field' attribute, replacing the user's field definition.

If no 'wizard:aggregation-group' property is set, the pre-processor will automatically pick the name of the group where this field is placed in. If the field is placed in the itemband or page-header/footer, the innermost group is used. If the field is placed in the report-header/footer, the group will evaluate to <null> and the aggregation will run for the whole report.

Advantages

  • Simplifies the most common usage of aggregations.

Disadvantages

  • Only generates display-aggregations. The aggregation-result cannot be reused in a computation.
  • Only works on fields that exist at the beginning of the report processing. It cannot work for fields that are dynamically generated during the report processing.
  • No labels