xtrareports-403729-feature-guide-to-devexpress-reports-shape-report-data-calculate-summaries-calculate-summaries-overview.md
You can calculate summaries across report data fields and use the summarized values in your report.
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:
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:
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 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:
Review the following help topic for information about calculated fields: Calculated Fields.
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>)
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.
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.