Count the Number of Groups in a Report

This document describes how to count the number of groups in a report.

Note

You can use this approach to counting groups when the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Expressions or DataBindingMode.ExpressionsAdvanced.

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

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

A report can display the total number of groups after binding your report to data and providing content to the report's detail band.

  • First, group the report's data. Switch to the Group and Sort panel and create a new group. Enable the Show Header option to display the group header in the report.

    group-data-category-name

  • Switch to the Field List and drop the group field onto the created group header.

    group-data-category-name-drop-onto-header

  • Right-click the report's surface and add a report footer to the report.

    add-report-footer-context-menu.png

  • Drop a label onto the report footer and invoke its smart tag. Set its Summary Running property to Report.

    label-expression-summary-running

  • Click the ellipsis button for the label's Expression property.

    label-expression-smart-tag-2

  • This invokes the Summary Expression Editor where you can specify the required summary function.

    summary-expression-sum-dcount

  • You can use the FormatString property to format the summary's value:

    summary-expression-sum-dcount-format

You can see the group count in the report footer when switching to Print Preview:

counting-groups-preview-result