Skip to main content
All docs
V24.2

Summaries Overview

  • 4 minutes to read

You can calculate summaries across report data fields and use the summarized values in your report.

Report Summaries

You can calculate summaries across values of a data field bound to the Text property of the XRLabel and XRTableCell controls. The Summary property specifies the summary type. The Report Designer invokes the Summary Editor to help the user set the summary options:

Summary Editor

When a summary type is specified (the Summary property is set), the control’s ExpressionBindings collection contains a binding to the Text property with an expression that uses a summary function.

If you use the Expression Editor to enter a summary function manually, set the Summary type beforehand. Otherwise, the summary functions are not available, and the expression is invalid.

Summary functions have the following specifics:

  • The function name has the sum prefix.
  • The functions are available only for the Text property of labels and table cells.
  • The XRSummary.Running option defines the function’s scope in the expression. In the expression, you cannot use a summary function for a data region other than the region that is defined with the Running option.
  • The data for which summary functions are calculated depend on report filters and other conditions that may hide data from the report.
  • The summary value is not available until the entire group or report is rendered.
  • The summary expressions as well as any other expression bindings should not reference values in other report controls. You should not use the ReportItems values in summary expressions.

Review the following help topic for the list of available summary functions: Functions for Summary Expression Editor.

The following help topics describe how to calculate report summaries:

Aggregate Functions

Aggregate functions allow you to summarize data with custom expressions. For more information on report expressions, review the following help section: Expressions Overview.

Aggregate functions have a broader scope than summary functions. Aggregate functions differ from summary functions in the following ways:

  • Aggregate functions are available in expressions bound to any bindable property and any control.
  • You can use aggregate functions in calculated fields because the functions are not restricted to any predefined group.
  • The data calculated with aggregate functions is available at any document generation stage, before and after the document is rendered.
  • Report filters and other conditions that may hide data from the report do not affect aggregates because aggregates are calculated at the data source level.

Review the following help topic for information about calculated fields: Calculated Fields.

Built-in Aggregate Functions

Review the following help topic for the list of available aggregate functions: Aggregate Functions in Expressions.

Use the following format to construct a valid aggregate expression:

[<Collection>][<Condition>].<Aggregate>(<Expression>)

  • <Collection> - Specifies a collection against which to calculate an aggregated value. It can be the relationship name for a master-detail relationship, or a collection property’s name exposed by the target class. For example, [CategoriesProducts][[CategoryId]>5].Count(). Empty brackets [] indicate the root collection.
  • <Condition> - Specifies a condition that defines which records to use for the aggregate function calculation. To calculate an aggregated value against all records, delete this logical clause and its square brackets (for example, [].Count()).
  • <Aggregate> - Specifies one of the available aggregate functions listed in the Aggregate enumeration.
  • <Expression> - Specifies the expression to use (for example, [][[CategoryID] > 5].Sum([UnitPrice]*[Quantity])). The Count function does not require field values to count the records (the round brackets can be empty for this function).

Use the Parent Relationship Traversal Operator (‘^’) to refer to the processed group (for instance, [][[^.CategoryID] == [CategoryID]].Sum([UnitPrice])). This operator allows you to calculate aggregates within groups.

The following table contains simple examples of how to use aggregate functions:

Expression Description
Sum([Quantity]) Grand total of the [Quantity] field for the report
[][[Discontinued] == True].Sum([Quantity]) Conditional grand total for discontinued items
[][[ProductName] == ^.[ProductName]].Sum([Quantity]) Calculates totals within the group (ProductName)
ToDecimal([Quantity]) / ([][[ProductName] == ^.[ProductName]].Sum([Quantity])) Calculates the perentage of the group total

For an example of use, review the following help topic: How to Use an Aggregate Function in Calculated Fields.

Custom Aggregate

The built-in function set contains only the basic functions. You can also create and register a custom function, and use this custom function in the Report Designer like any other function.

Custom aggregate functions can handle collections, not single fields. You can pass field names to a custom function and calculate any value. For more information, review the following help topic: Custom Aggregate Functions.