ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1Report > Grouping and Sorting Data > Adding Running Sums

Adding Running Sums

C1Report field objects have a RunningSum property that makes it easy to maintain running sums over groups or over the entire report.

Adding Running Sums over a Group

To keep running sums over groups, complete the following tasks:

1.   Open the C1ReportDesigner application. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.

2.   Create a new report or open an existing report. Once you have the report in the C1ReportDesigner application, you can modify the report properties.

3.   Click the Design button to begin editing the report.

4.   In Design mode, select the report from the drop-down list above the Properties window. The available properties for the report appear.

5.   Add a calculated field to the report:

a.   Click the Add Calculated Field button from the Designer toolbar.

b.   In the VBScript Editor, enter the following script:

Sum(ProductSalesCtl)

c.    Drag the mouse over the GroupHeader section of the report and the cursor changes into a cross-hair . Click and drag to define the rectangle that the new field will occupy, and then release the button to create the new field.

6.   Set the RunningSum property to SumOverGroup. (Note that for this property to appear, the properties filter must be turned off. It's the funnel icon above the Properties window.)

Adding Running Sums over the Entire Report

To keep running sums over pages, you need to use script. For example, you could add a pageSum field to the report and update it with script. To do this, complete the following tasks:

1.   Open the C1ReportDesigner application. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.

2.   Create a new report or open an existing report. Once you have the report in the C1ReportDesigner application, you can modify the report properties.

3.   Click the Design button to begin editing the report.

4.   In Design mode, select the report from the drop-down list above the Properties window. The available properties for the report appear.

5.   Locate the OnPage property and click the empty field next to it, and then click the ellipsis button.

6.   The VBScript Editor appears. Enter the following VBScript expression in the code editor:

' VBScript: Report.OnPage

pageSum = 0

7.   Then select Detail from the drop-down list above the Properties window. The available properties for the Detail section appear.

8.   Locate the OnPrint property and click the empty field next to it, and then click the ellipsis button.

9.   The VBScript Editor appears. Enter the following VBScript expression in the code editor:

' VBScript: Detail.OnPrint

pageSum = pageSum + UnitsInStock

* Sample Report Available

For the complete report, see report "17: Running Sums" in the CommonTasks.xml report definition file, which is available for download from the CommonTasks sample on the ComponentOne HelpCentral Sample page.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.