To calculate the sum of a column (Number) or count the occurrence of a specific value, one could easily iterate and add (or count) the values. This however causes a considerable overhead and is often error prone.
Using Groovy expressions this can be implemented fast, easily and safely.
Consider the example were we have master-detail tables “Departments” and “Employees”. In the “Employees” table we have (among others) column “Salary” with number values and column “isActive” with “Y” or “N” values. If we need to display the sum of all salaries for a specific department (“Total Salaries”) and the number of active employees (“Total Number of Active”), we could simply calculate the two fields (as Transient attributes) in the Departments view object. For “Total Salaries” attribute in value type check “Expression” and in the value set: Employees.sum(“Salary”). For “Total Number of Active” attribute set value to Employees.sum(“isActive == ‘Y’ ? 1 : 0″)