Group Data On Axes

Data sources contain detailed information whereas summary reports often require only a general overview of the data stored within the database. With the ExpressPivotGrid 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 Values

ExpressPivotGrid 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 exactly match 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:

  • Set the desired field's GroupInterval property to giCustom.
  • Handle the field's OnGetGroupValue event. 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 field value in the current record is negative and 1 if not.
  • Handle the field's OnGetGroupValueDisplayText 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:

[Delphi]

procedure TForm1.FieldAgeGetGroupValue(Sender: TcxPivotGridField;
  ARecordIndex: Integer; var AValue: Variant);
begin
  AValue := cxDBPivotGrid1.DataController.GetValue(ARecordIndex, FieldAge.Index);
  if AValue < 30 then AValue := 0
  else AValue := 1;
end;

procedure TForm1.FieldAgeGetGroupValueDisplayText(
  Sender: TcxPivotGridField; const AGroupValue: Variant;
  var AText: String);
begin
  if AGroupValue = 0 then AText := 'Under 30'
  else AText := 'Over 30';
end;

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

Because the ExpressPivotGrid 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.

Back to the Feature List

LIVE CHAT

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, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

Your Privacy - Legal Statements

Copyright © 1998-2013 Developer Express Inc.
ALL RIGHTS RESERVED
All trademarks or registered trademarks
are property of their respective owners