property Pivot.Aggregates as Aggregates

Retrieves the Aggregates collection of the pivot control.

Type | Description | |||

Aggregates | The Aggregates collection that holds the Aggregate objects. |

The Aggregates property gives access to the Aggregates
collection. The Aggregates collection holds a collection of Aggregate objects. An aggregate function is a function where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning or measurement such as a set, a bag or a list.
The Aggregate object is identified by an unique key. By default, the
Aggregates collection contains the "sum", "min",
"max", "count" or "avg" Aggregate objects. Use
the Add method to add a new Aggregate
function/object to the control. Use
the FormatValue/FormatResult
property to convert/format the value/result of the Aggregate function. The PivotColumns
or PivotTotals property to display
aggregate functions on the columns. Use the FormatPivotAggregate
/ FormatPivotTotal property to
display aggregate functions in a different format.

The following screen shot shows the Aggregate objects in the control's context menu:

By default, the Aggregates collection contains the following elements:

**"sum"**, summation is the operation of adding a sequence of numbers; the result is their sum or total**"min"**, minimum is the smallest value**"max"**, maximum is the largest value**"count"**, counts the number of objects in the set**"avg"**, average is the arithmetic mean, which means sum of all numbers divided by the count.

For instance:

- you want to get the total for negative values or to count the positive value only. In this case, you can add a new Aggregate object such as Aggregates.Add("negative", "sum").FormatValue = "value < 0 ? value : 0", and so the negative Aggregate function gets the total of negative values only.
- The Aggregates.Add("positive", "sum").FormatValue = "value < 0 ? 0 : 1", counts the number of positive values.