In ActiveReports, summary fields can be added to any section to calculate totals, counts, averages and other aggregations. The summary field's placement dictates when the section containing the field, and sections after it, will be printed. A section with a summary field will be delayed until all the calculations are completed. This allows summary fields to be placed ahead of the corresponding detail.
Summary fields are calculated according to the textbox's Summary properties. A summary textbox is updated with each new detail record. When a field is placed ahead of the Detail section (i.e. in the ReportHeader, PageHeader or GroupHeader sections), the Detail section is formatted with each record and the summary field is updated. When all records for the summary level are read, the header section is printed followed by the delayed sections.
To add a group summary field
- Right-click the design surface of the report and select Insert, then Group Header/Footer to add a group header and group footer section to the report.
- With the group header selected in the Properties window, change the DataField property to the field on which to group the report.
- Drag a field that you want to summarize onto the group footer section and set its properties as follows:
- SummaryType = SubTotal
- SummaryRunning = Group
- SummaryGroup = YourGroupHeaderName
To add a report summary field
- Right-click the design surface of the report and select Insert, then Report Header/Footer to add a report header and group footer section to the report.
- Drag a field that you want to summarize onto the report footer section and set its properties as follows:
- SummaryType = GrandTotal
- SummaryRunning = All
|Note: The SummaryRunning property is only set when the SummaryType is GrandTotal or SubTotal, otherwise it is set to None.|
Distinct summarization can be used in a situation when the field's value repeats in several detail records and the summary function needs to include a single value from all repeating values. To do this, you would need to set the DistinctField property of the summary field to the appropriate value and set the SummaryFunc property to the appropriate distinct summary function (for example, DSum for distinct summary or DCount for distinct count).