Aggregate Calculation

UDP ›› Calculations ››
Parent Previous Next

Aggregate Calculation

The Aggregate Calculation performs calculations on a number of business objects or business object groups and/or their attributes, for example, calculates the sum total of an attribute:

   

SUM Account.Balance

   

The calculation above calculates the total balance of all available accounts.

   

The calculation may be applied not only to all available business objects of the specified type, but also to objects that meet the specified condition. The condition can be specified after the WHERE keyword and must be enclosed in brackets, for example:

   

SUM Account.Balance WHERE (Account.State='OPEN')   

   

The calculation above calculates the total balance of all open accounts. The condition that follows the WHERE keyword can have one or more expressions connected with the AND or OR keywords – just like a conditional part of a rule ((see Rule Condition).

   

The following types of the Aggregate Calculation are supported:

   

1.      SUM – calculate sum total of an attribute.

2.      COUNT – calculate the number of available objects.

3.      MIN – calculate minimum value of an attribute.

4.      MAX – calculate maximum value of an attribute.

5.      AVG – calculate average value of an attribute.

   

  NOTE:  SUM, MIN, MAX, AVG calculations must not use attributes of the Reference type, for example the following expression is not valid:

   

SUM Account.Transactions.Amount  

   

If aggregate of the referred object is required as in the example above, the following expression must be used:

   

SUM Transaction.Amount WHERE (Transaction IN Loan.Transactions)  

   

  NOTE: The COUNT calculation must only use the names of business objects or business object groups – it is not allowed to use attributes, for example,  

   

COUNT Account or COUNT Account WHERE (Account.State='Open').  

   

Using references is also not allowed in the COUNT calculation, for example the following expression is invalid:

   

COUNT Account.Transactions.  

   

The valid expression that achieves the desired result is:

   

COUNT Transaction WHERE (Transaction IN Account.Transactions)  

   

  NOTE:  The Aggregate Calculation uses instances of business objects that exist in the system's database, not in the current Context – see Aggregate Operations.