Adding an Aggregate Field to the Data Report

See Also

In the Data Environment designer you can also create aggregate fields—fields that summarize data from a section. An aggregate field is thus similar to the Function control in that both are calculated as the report is generated. But there are a few differences: whereas the Function control can only be placed in a Group Footer, an aggregate field can be placed in any section of the Data Report designer, except the Report Header/Footer and Page Header/Footer sections.

Another difference is found in how the two fields are created: while the Function control is a feature of the Data Report designer, the aggregate field is a feature of the Data Environment designer. The steps to adding an aggregate field to the report are:

  1. Create an aggregate field in the Data Environment designer.

  2. From the Data Environment designer, drag the aggregate field onto the Data Report designer.

As an example, the figure below shows an aggregate field that displays the number of products ordered.

Data Report with Aggregate Field

Using a Function control can be more efficient than an aggregate field. When the data report calculates the value for a Function control, it takes a certain amount of processing to create each value. When the data environment creates an aggregate field, it takes a similar amount of processing. However, you can save that processing time by using the Function control because the Data Report designer must create the entire report in its own process.

Note   This topic is part of a series that walks you through creating a sample data report. It begins with the topic, Creating a Simple Data Report.

To create an aggregate field in the data environment

  1. On the Data Environment designer, open the Detail Fields in Customers folder, and right-click Orders, then click Properties.

  2. On the Orders Properties dialog box, click the Aggregates tab.

  3. Click the Add button.

  4. Click the Name box and type ProductCount.

  5. In the Function combo box, select CNT.

  6. In the Aggregate combo box, select OrderDetails (it should be selected by default).

  7. In the Field combo box, select ProductID.

  8. Click OK to close the dialog box.

Now that you have created the aggregate field, you can place it on the Data Report designer.

To Add the aggregate field to the data report

  1. From the Data Environment designer, drag the ProductCount aggregate field onto the group section named Orders_Header.

  2. Change the Caption of the Label control to Product(s) Ordered.

  3. Reposition and resize the TextBox control and the Label control so the designer resembles the figure below:

  4. Save and run the project.

Step by Step

This topic is part of a series that walks you through creating a sample data report.

To See
Go to the next step Grouping Information in the Data Report
Start from the beginning Creating a Simple Data Report