Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Collapse]Reporting
 [Expand]Product Information
 [Expand]Getting Started
 [Expand]Fundamental Concepts
 [Collapse]Concepts
  [Expand]Report Types
  [Expand]Report Controls
  [Expand]Platform-Specific Reporting
  [Collapse]Creating Reports
   [Expand]Providing Data to Reports
   [Expand]Providing Data To Report Controls
   [Collapse]Shaping Data
     Grouping Data
     Sorting Data
     Filtering Data
     Calculating Summaries
     Formatting Data
   [Expand]Using Report Parameters
   [Expand]Appearance Customization
   [Expand]Navigation and Interaction
   [Expand]Scripting
  [Expand]Storing Reports
  [Expand]Publishing Reports
  [Expand]End-User Reporting
  [Expand]Application Appearance
  [Expand]Migration to XtraReports
 [Expand]Design-Time Features
 [Expand]Examples
  End-User Capabilities
 [Expand]Localization
 [Expand]Redistribution and Deployment
 [Expand]API Reference
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
[Expand]End-User Documentation

Calculating Summaries

This document describes a way of calculating a summary for a data-bound label either based on one of the built-in functions or based on a custom summary that is specified in the control's XRControl.BeforePrint event. To learn how to employ scripts for summaries calculation, refer to Calculating Custom Summaries via Scripts.

This document consists of the following sections.

Expanded Calculating an Automatic Summary

For a data-bound XRLabel control (or its descendants), XtraReports supports automatic calculation of various summary functions across a data field from where the label obtains its content. The functions include total, maximum, minimum, average, count and many others. The complete list of functions available is returned by the SummaryFunc enumeration.

Note

A summary value can only be correctly calculated if a label is bound to data of numeric or System.TimeSpan type. For System.String values, it is only possible to auto-calculate the following functions: Count, DCount and RecordNumber.

To calculate an automatic summary for a label do the following.

  • Bind a label to the data to be summarized. Note that a summary is calculated only if data is bound to the XRControl.Text property of a label. For details on this, refer to Providing Data To Report Controls.

  • Expand the XRLabel.Summary property to view all the options provided by the XRSummary object.

    Or click the ellipsis button of this property to adjust all settings using Summary Editor.

  • First, you should specify the actual function which is to be calculated via the XRSummary.Func property. It is set to Sum (plain summary) by default.

  • Specify the range within which data should be summarized via the XRSummary.Running property. An automatic summary can be calculated for values within a group, a page or the entire report.

    Note that the summary label should be placed onto a band that corresponds to the specified summary range. So, for example, if a summary is to run through page, the summary label should be placed onto PageHeaderBand or / and PageFooterBand. Or, if a summary is being calculated for a group, then the summary label should be placed onto the corresponding GroupHeaderBand or GroupFooterBand.

    Note

    Moreover, in order to calculate a summary it is critical that another label be placed in the report's Detail band, which is bound to the same data field that is to be summarized by the summary label. The label in the Detail band comprises a report's general data and if empty, the summary becomes empty as well with no regard as to which range is specified for it and onto which band it is placed.

  • Other summary options are represented by the XRSummary.FormatString and XRSummary.IgnoreNullValues properties.

Note that since the summary value is calculated after the XRControl.BeforePrint event is raised, its result cannot be obtained within this event. Use the XRSummary.GetResult method to obtain a summary's value. Or handle the XRLabel.SummaryCalculated event to custom calculate the summary value and perform any additional actions required after its calculation.

Expanded Calculating a Custom Summary

If no built-in summary function meets your requirements, you can calculate a custom summary function with XtraReports. Do the following:

For a step-by-step tutorial illustrating this approach, refer to How to: Calculate a Custom Summary.

Sometimes, you may be required to calculate complex functions based on results of other summary functions. In such tasks, the summary functions' results are obtained in the XRLabel.SummaryCalculated event handlers of the corresponding XRLabel and the resulting aggregate is assigned to another label's Text property in its XRControl.PrintOnPage event handler.

Expanded Examples

Expanded See Also

How would you rate this topic?​​​​​​​