I am using Stimulsoft Reports. How can I get the sum value of a field in a table on the page, not all reported?
2 Answers
It is very simple to calculate totals of a container or a page. For this it is necessary to add before the name of an aggregate function the Latin letter 'c' in lowercase. For example:
{cCount(DataBand1)}
This expression will return the number of rows of one page.
Notice. A page is a container too. Therefore, calculation of totals of a page goes the same way as calculation of totals of a container.
When calculation of totals of a panel or of a page it is necessary specify the Data band by what the aggregate function will be calculated. It is necessary because more than one Data band can be placed on one page.
Any number of aggregate functions can be used on one page or a panel. Stimulsoft Reports has no limit in it. It is possible to combine totals of a page with a condition. For example:
{CountIf(DataBand1, Products.UnitsInStock = 0)}
The expression will return the number of elements equal zero on this page.
In Stimulsoft Reports calculation of totals can be produced in another way - instantly. You should use the special Totals prefix. Calculation of totals occurs where the function is called, in contrast to standard results, calculations are performed while report rendering.
Consider the calculation of totals in a report by the example of a report with grouping. Calculate the ratio of entries in the group to entries in the report and show the total in per cent. To do this, add a text component in the GroupFooterBand with the following
{Count(DataBand1) / (double)Totals.Count(DataBand1)}
expression, where the Count(DataBand1) function will count the number of rows in the group, and the Totals.Count(DataBand1) function will calculate the number of rows in the report. To show the total value in per cent, you should to set the Text Format property of the text component to Percentage.

- 86
- 3