BackPrevious Page Next PageNext

Business View Elements

The following are elements contained in business views.

Custom aggregations

Custom aggregations are special aggregations used for sophisticated mathematic and logic calculation purposes. They are created using the Formula Editor and are defined based on the elements in a business view and the built-in functions including aggregation functions, mathematic and logic calculation related functions. Custom aggregations can be created as aggregation objects or as dynamic formulas that are used as aggregations in a business view.

When using a custom aggregation in a data component, you need to make sure the group elements referenced in the custom aggregation are also added as table group-by field, crosstab column/row field or chart category/series field in the data component.

Custom aggregation expression

The expression for a custom aggregation is defined by relative member set and aggregation. It returns a single value or an array.

The general expression structure of a custom aggregation is @(<Group Collection>, <Aggregation>) or @(<Group Collection>, <Detail>).

The following details each segment in the expression.

Here are some custom aggregation expression examples:

Calculation logic

The calculation of custom aggregations is based on data components. The following introduces the calculation logic in a crosstab. Calculation on chart category and series is similar to that on crosstab. Other components with group structure can be regarded as one-direction crosstabs.

  1. Check whether every group of the crosstab is included in the original custom aggregation expression. If a group is not included, JReport adds @Group:CURRENT into the expression.

    For exmaple, a custom aggregation is defined as @(@Year:CURRENT, @Month:CURRENT, Sum(@Sales)), which contains the two groups @Year:CURRENT and @Month:CURRENT, when it is used in a crosstab with row header Country and column header Region, Country and Region will also determine member combination, so the expression will be @(@Year:CURRENT, @Month:CURRENT, @Country:CURRENT, @Region:CURRENT, Sum(@Sales)).

    If a custom aggregation uses variable as <Group Name> in the expression, such as CURRENT, CROSSTAB_ROW, CROSSTAB_COLUMN, CHART_CATEGORY, and CHART_SERIES, during the calculation the variable need to be replaced by a group name in the data component, and which group name will be used depends on the position where the custom aggregation is inserted in the data component.

  2. Replace every member value CURRENT using the member of the cell where the custom aggregation is inserted, which could be a constant value or ALL.

    In the above example, JReport knows Country and Region member values of the cells, but cannot know that of Year and Month, so Year and Month members are ALL, and the expression will be @(@Year:ALL, @Month:ALL, @Country:"USA", @Region:"CA", Sum(@Sales)).

  3. Return the aggregation value based on the member combination. If there is not any CHILDREN member/member set in the combination, it returns a single value, or else returns an array, and the order of the array elements should be according to column and row order of the crosstab. When member cannot be gotten, the aggregation expression will return the value "Null".

When the Running functions are used in the custom aggregation expression, if the group member combination does not have relative cell in the crosstab, it returns Null.

During the custom aggregation calculation, error may occur when any of the following happens:

BackPrevious Page Next PageNext