Grouping Values
- 2 minutes to read
By default, all the unique field values of column and row fields are listed along the control’s top and left edges. These values represent headers of the categories (columns and rows) - the axes of the report. For each intersection of columns and rows, the ExpressPivotGrid calculates and displays a summary against a data field for a subset of records. All the records from this subset have matching values in a column field(s) and row field(s) and these values are identified by column and row headers.
The ExpressPivotGrid provides a grouping feature - specific field values can be automatically grouped into bigger categories (ranges). The grouping feature is especially useful for representing date-time and numeric data. For instance, the values of a column or row field which displays date-time data can be grouped by years, months, quarters, etc. Unique numeric values can be grouped into numeric ranges. String values can be grouped by the starting characters of the values.
In the following image two ExpressPivotGrid controls are shown. The first one displays the original data before it’s grouped. The second control groups values of the ‘Purchase Date’ column field by months.
Now each column in the second grid summarizes the values of appropriate columns in the first grid. For instance, the values in the ‘January’ column are sums of the values in the first three columns in the first grid as these columns refer to January.
To specify grouping mode for a column/row field, use its GroupInterval property. If the field contains numeric values, use the GroupIntervalRange property to specify the length of the intervals. For instance, if this property is set to 10 the values will be combined into the following intervals: 0-9, 10-19, 20-29, etc.
Note
If the standard grouping modes do not suit your requirements you can implement custom grouping intervals.
Multiple fields in the ExpressPivotGrid control can be bound to the same field in the underlying data source. The values of these fields can be grouped independently. For instance, it’s possible to create two fields and bind them to the PurchaseDate field in the data source. The first field can group data by years, the second field - by months. To distinguish these fields in the control, you can specify appropriate descriptive captions for them as shown in the image below.