DefaultAggregation Annotations

Specifies aggregation behavior on element level

Scope and Definition

@Scope:[#ELEMENT]
Annotation DefaultAggregation : String enum { NONE; SUM; MIN; MAX; AVG; COUNT; COUNT_DISTINCT; FORMULA; };

Usage

Annotation Meaning

DefaultAggregation

When the DefaultAggregation annotation has been specified for an element, the corresponding elements are used as so called measures (elements that can be aggregated) both in standard CDS QL scenarios and on analytical scenarios.

Scope: [ELEMENT]

Evaluation Runtime (Engine):

Values:

Value Description
SUM, MAX, MIN, AVG, COUNT, COUNT_DISTINCT All these values determine the default aggregation of the measure.
FORMULA The value FORMULA indicates, that the element is a formula which has to be calculated after the operands have been determined by aggregation or calculation. It should never be aggregated.

Example: Margin : = Revenue / Cost. If in a report Margin should be shown per OrgUnit, then first the aggregates of Revenue and Cost have to be determined per OrgUnit and then the Margin has to be calculated per OrgUnit.

NONE This value indicates that the element is not a measure. Usually these elements are used in filters and GROUP BY statements.
NOTE

If no DefaultAggregation annotation is assigned to an element, the engine assumes the aggregation behavior for values FORMULA for formulas and NONE value (no aggregation takes place) for other select list entries. Since these are the default values assumed when DefaultAggregation is absent, this annotation may be omitted altogether (Exception: addressing of 1ROWCOUNT - see example Counters and exception aggregation below).

Examples

Example 1

Counters and exception aggregation

For CDS views representing master data reports (i.e. the FROM clause refers to a CDS view categoriezed as #DIMENSION), a counter of the different dimension values can be defined by combining the annotation DefaultAggregation: #SUM with a select list entry containing constant value 1:

This way no exception aggregation is involved which leads to improved performance of the report.