Expression with Aggregate Functions |
Top Previous Next |
To sum up all values of one column it is enough to write the following text expression of a component:
{Sum(DataSource.Column)}
Also it is acceptable to use complex expressions:
{100 + Sum(DataSource.Column) * 2}
For example, it is necessary to output number of rows and the sum of values. For this, it is necessary to add the Footer band to the report. Put two Text components on this band. Write in the first component the following expression:
{Count()}
in this component the number of rows will be output.
Write in the second component the following expression:
{Sum(Products.UnitsInStock)}
in this component the sum of values of the UnitsInStock column will be output.
As one can see from the sample, there is no need in additional arguments for calculation of number of rows of the Count function. One argument was specified to the Sum function. It is the expression that should be summed up. In other words the report generator specified to which Data band all these aggregate functions belong to and how many times these functions must be called.
This occurred because text components, in which aggregate functions was used, were placed on the total Footer band. This band belongs to a Data band. This enables the report generator to bind the aggregate functions and the Data band automatically. There are several types of total bands in Stimulsoft Reports. They are as follow:
Placing components and aggregate functions together allows the report generator to indicate to which Data band do these aggregate functions belong. Also, in addition, it is possible put the component with aggregate function on the Data band. In this case there will be an output of the result of an aggregate function calculation of all strings.
|
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |