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.

Developer Express WinForms Pivot Grid provides several data grouping options - alphabetic, customizable numeric ranges, date-time intervals

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.

Different versions of the same pivot report. Date axis values are grouped by days, months and years.

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.

A sample pivot report that doesn't group axis values

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:

C#
VB
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";
}

And with just a few lines of code, you get a completely different view.

The same report as on the previous screenshot, only with grouping applied to Age values

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

Subscribe Today

It's Your Choice: All DevExpress WinForms Controls can be purchased as part of the following Subscriptions:
Universal Subscription
DXperience Enterprise
WinForms Controls

What's New in 2012

The best keeps on getting better. Our newest WinForms controls and features include:

WinForms Tech Library

Explore the power of the DevExpress WinForms product line at your pace with the following online technical resources:

Our Awards


              DevExpress Awards : Windows IT Pro Community Choice
              DevExpress Awards : Visual Studio Magazine Readers Choice
              DevExpress Awards : SDTimes 100
              DevExpress Awards : ComponentSource Bestselling Publishers
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.