Skip to main content
A newer version of this page is available. .

Count the Number of Groups in a Report

  • 2 minutes to read

This tutorial demonstrates how to count the number of groups in a report using the DCount summary function. This function counts the number of unique records in the defined data field.

Note

This approach to calculating the number of report groups applies when the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Bindings.

See Count the Number of Groups in a Report to learn about the alternative approach to solving this task.

See Data Binding Modes to learn more about the available binding modes.

The following image illustrates the report created in this tutorial:

HowTo_CountGroups_5

Do the following to count the number of groups in a report:

  1. Start with the report created in the Group and Sort a Report’s Data tutorial.
  2. Add the Report Footer band to display the number of groups at the bottom of the report. Right-click anywhere on the report designer, and in the context menu, select Insert Band and then ReportFooter.

    Shared_BandsAddReportFooter

  3. Copy the label from the Group Header to the Report Footer by dragging this label while pressing the CTRL key.

    HowTo_CountGroups_4

  4. Select the created label and click its smart tag. In the invoked actions list, set the Summary Running property (XRSummary.Running) to Report to calculate a summary for the entire report.

    Set the Summary Func (XRSummary.Func) to DCount and define a format string (XRControl.TextFormatString).

    HowTo_CountGroups_3