Skip to main content

TcxPivotGridField.OnCalculateCustomSummary Event

Occurs when a summary value needs to be calculated manually.

Declaration

property OnCalculateCustomSummary: TcxPivotGridCalculateCustomSummaryEvent read; write;

Remarks

To enable custom summary calculation for a field (either a data field or the field whose values are used by the “sorting by summary“ feature), set the field’s SummaryType property to stCustom and handle the OnCalculateCustomSummary event to provide a custom summary for a data cell. The field is passed as the Sender parameter.

The ASummary parameter of the TcxPivotGridCrossCellSummary type stores all the calculated summary values and the settings used to calculate them. For more information, refer to the description of the TcxPivotGridCrossCellSummary type.

To specify a custom summary value for the field, set the ASummary.Custom property to this value. If the field is in variation mode, you can also specify the difference between this value and the previously calculated summary value via the SummaryVariation property.

The following code snippet demonstrates how to calculate the average value using the pre-calculated summary values. Note that the function that calculates the average value is a built-in summary function and the code below is for demonstration purposes only.

ASummary.Custom := ASummary.Sum / ASummary.Count;

For more information on custom summaries, refer to the How to Calculate Custom Summaries topic.

See Also