Data sources contain detailed information whereas summary reports often require only a general overview of the data stored within the database. With the XtraPivotGrid you can group values using predefined intervals or provide your own intervals as needed. Both approaches are extremely simple as demonstrated below.
Use Built-in Mechanisms to Group Axis Values
XtraPivotGrid fields expose a GroupInterval property which allows you to merge field values into groups. By changing just a single property you can group date-time values by months, years, etc. Along with date-time group intervals, this property allows you to group values using numeric intervals or alphabetically. When grouping alphabetically, text values are joined into groups by comparing their starting characters.
The following image shows a complete list of self-explanatory options offered by the GroupInterval property.

So by altering the value of a single property you can display different levels of detail and address the needs of your end-users. The image below demonstrates the default appearance of the date-time axis and the effect that applying various group intervals has. 
You can generate a more flexible report by displaying values hierarchically. You can create several fields bound to a DateTime field and specify different group intervals. Thus, end-users will be able to expand and collapse hierarchy nodes so that in a single report they can view the data by years, months or dates. Learn more about this feature here.
Group Values Manually
These built in grouping algorithms will address a wide range of business scenarios, but are by no means the only options available to you. You can easily group axis values using your own criteria. To implement custom group intervals, follow the simple steps below:
- Add an unbound field;
-
Handle the control's CustomUnboundFieldData event. Use this event to supply group values to the unbound field. For instance, if you need to have two groups in a numeric axis - with both positive and negative values, you can specify -1 if the target field has a negative value and 1 if not.
-
Handle the control's FieldValueDisplayText event to substitute group values with user-friendly text. For instance, in the previous example, you can handle this event to replace the 1 and -1 values with the words "Positive" and "Negative" respectively.
Now let's see how manual group intervals can be implemented in a real example. The image below shows a sample report with the average salary and seniority displayed for employees. Employees are grouped by their age and department. 
To compact the report further and make it more readable, lets group the values in the Age axis. This axis will show two intervals ("Under 30" and "Over 30") rather than display each unique age. To achieve this aim, all you need to do is to create an unbound field and write two short event handlers:
|
private void pivotGridControl1_CustomUnboundFieldData(object sender, DevExpress.XtraPivotGrid.CustomFieldDataEventArgs e) { if(e.Field != fieldAgeRange) return; if((int)e.GetListSourceColumnValue("Age") > 30) e.Value = 1; else e.Value = 0; } private void pivotGridControl1_FieldValueDisplayText(object sender, DevExpress.XtraPivotGrid.PivotFieldDisplayTextEventArgs e) { if(e.Field != fieldAgeRange) return; e.DisplayText = ((int)e.Value == 1) ? "Over 30" : "Under 30"; }
Private Sub pivotGridControl1_CustomUnboundFieldData(ByVal sender As Object, _ ByVal e As DevExpress.XtraPivotGrid.CustomFieldDataEventArgs) _ Handles pivotGridControl1.CustomUnboundFieldData If Not (e.Field Is fieldAgeRange) Then Return If CInt(e.GetListSourceColumnValue("Age")) > 30 Then e.Value = 1 Else e.Value = 0 End If End Sub
Private Sub pivotGridControl1_FieldValueDisplayText(ByVal sender As Object, _ ByVal e As DevExpress.XtraPivotGrid.PivotFieldDisplayTextEventArgs) _ Handles pivotGridControl1.FieldValueDisplayText If Not (e.Field Is fieldAgeRange) Then Return If CInt(e.Value) = 1 Then e.DisplayText = "Over 30" Else e.DisplayText = "Under 30" End If End Sub
|
And with just a few lines of code, you get a completely different view. 
Because the XtraPivotGrid offers you complete control over individual axis, you can deliver a wealth of business value to your customers with only a few lines of source code.
Learn More: Help Topic: Grouping Values on Axes | Help Topic: How to Group Date-Time Values | Help Topic: How to Implement Custom Group Intervals | Help Topic: How to Add an Unbound Field to Change Axis Detailing |