PivotGridFieldBase.GroupInterval Property

Gets or sets how the values of the current column or row field are combined into groups.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v21.1.Core.dll

Declaration

[DefaultValue(PivotGroupInterval.Default)]
public PivotGroupInterval GroupInterval { get; set; }

Property Value

Type Default Description
PivotGroupInterval

Default

A PivotGroupInterval value that specifies how the values of the current field are combined into groups.

Available values:

Show 26 items
Name Description
Default

Groups combine unique field values.

Date

This option is in effect only for fields that store date/time values.

Field values are grouped by the date part. The time part of the values is ignored.

DateDay

This option is in effect only for fields that store date/time values.

Field values are grouped by the day part. The following groups can be created: 1, 2, 3,…,31.

DateDayOfWeek

This option is in effect only for fields that store date/time values.

Field values are grouped by the days of the week. Examples of such groups: Sunday, Monday, Tuesday (the actual names of the days of the week are determined by the current culture).

DateDayOfYear

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of the day in which they occur in a year. The following groups can be created: 1, 2, 3,…,365 (,366 in a leap year).

DateWeekOfMonth

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of the week in which they occur in a month. The following groups can be created: 1, 2, 3, 4 and 5. The first week is the week containing the 1st day of the month.

DateWeekOfYear

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of the week in a year in which they occur. The following groups can be created: 1, 2, 3,…,52, 53.

Week numbers are calculated based on the following current culture’s settings: the CalendarWeekRule and FirstDayOfWeek properties.

DateMonth

This option is in effect only for fields that store date/time values.

Field values are grouped by the month part. Examples of groups: January, February, March (the actual names of the months are determined by the current culture).

DateQuarter

This option is in effect only for fields that store date/time values.

Field values are sorted by the quarterly intervals of the year. The following groups can be created: 1, 2, 3 and 4. Each quarter includes three months.

DateYear

This option is in effect only for fields that store date/time values.

Field values are grouped by the year part. Examples of such groups: 2003, 2004, 2005.

YearAge

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of full years that have elapsed till the current date. The lengths of groups is determined by the PivotGridFieldBase.GroupIntervalNumericRange property.

MonthAge

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of full months that have elapsed till the current date. The lengths of groups is determined by the PivotGridFieldBase.GroupIntervalNumericRange property.

WeekAge

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of full weeks that have elapsed till the current date. The lengths of groups is determined by the PivotGridFieldBase.GroupIntervalNumericRange property.

DayAge

This option is in effect only for fields that store date/time values.

Field values are grouped by the number of full days that have elapsed till the current date. The lengths of groups is determined by the PivotGridFieldBase.GroupIntervalNumericRange property.

Alphabetical

Combines field values into categories according to the character that the values start with.

Numeric

This option is in effect only for fields that store numeric values.

Field values are grouped into intervals as defined by the PivotGridFieldBase.GroupIntervalNumericRange property.

Hour

This option is in effect only for fields that store date/time values.

Field values are grouped by the hour part, regardless of the date to which the current date/time value belongs.

Custom

Enables combining the field’s data into custom intervals via the PivotGridControl.CustomGroupInterval event.

Not supported in OLAP mode.

Minute

This option is in effect only for fields that store date/time values.

Field values are grouped by the minute part, regardless of the date to which the current date/time value belongs.

Second

This option is in effect only for fields that store date/time values.

Field values are grouped by the second part, regardless of the date to which the current date/time value belongs.

DateMonthYear

This option is in effect only for fields that store date/time values.

Field values are grouped by months and years. Examples of groups: August 2013, September 2014, January 2015, …

DateQuarterYear

This option is in effect only for fields that store date/time values.

Field values are grouped by the year and quarter. Examples of groups: Q3 2012, Q4 2012, Q1 2013, Q2 2013, …

DateHour

This option is in effect only for fields that store date/time values.

Field values are grouped by the date part with the hour value. Examples of such groups: 3/4/2012 0:00, 3/4/2012 1:00, 3/4/2012 2:00, …

DateHourMinute

This option is in effect only for fields that store date/time values.

Field values are grouped by the date part with the hour and minute values. Examples of groups: 3/4/2012 0:00, 3/4/2012 0:01, 3/4/2012 0:02, …

DateHourMinuteSecond

This option is in effect only for fields that store date/time values.

Field values are grouped by the date part with the hour, minute and second values. Examples of groups: 3/4/2012 0:00:00, 3/4/2012 0:00:01, 3/4/2012 0:00:02, …

DateWeekYear

This option is in effect only for fields that store date/time values.

Field values are grouped by the date of the first day of the week (uses culture settings). Examples of such groups: 7/1/2018, 7/8/2018, 7/15/2018.

Remarks

Run Demo: Interval Grouping

The control doesn’t group values of the column and row fields. It displays all their unique values along its left and top edge. You can use the GroupInterval property to change the logic and specify which values should be grouped together.

For instance, for a field that displays date/time values, you can set its GroupInterval property to PivotGroupInterval.DateYear. As a result, the field’s values will be grouped within a few categories, each of which will combine different values that belong to the same year.

To display a group interval name in the field’s caption, set the PivotGridFieldOptions.ShowGroupIntervalName property to true.

See the PivotGroupInterval topic for details on the available group modes.

You can control which group interval to display in the UI. For this, set the PivotGridOptionsMenu.ShowDateTimeGroupIntervalItems property.

If group modes available from the GroupInterval property do not suit your needs, you can use the PivotGridControl.CustomGroupInterval event to implement custom group intervals.

Example

Assume that the PivotGridControl is bound to a data table that contains an OrderDate field. In the following example two PivotGridField fields are created and displayed in the Column Header Area. Each is bound to the OrderDate field. The first Pivot Grid Control field’s values will be grouped by years, the second field’s values will be grouped by months. To group data, the PivotGridFieldBase.GroupInterval property is used.

The result of the code is shown below:

PivotGridField_GroupInterval_ex

using DevExpress.XtraPivotGrid;

// Create column fields and bind them to the 'OrderDate' datasource field.
PivotGridField fieldYear = new PivotGridField("OrderDate", PivotArea.ColumnArea); 
PivotGridField fieldMonth = new PivotGridField("OrderDate", PivotArea.ColumnArea);
// Add the fields to the field collection.
pivotGridControl1.Fields.Add(fieldYear);
pivotGridControl1.Fields.Add(fieldMonth);
// Set the caption and group mode of the fields.
fieldYear.GroupInterval = PivotGroupInterval.DateYear;
fieldYear.Caption = "Year";
fieldMonth.GroupInterval = PivotGroupInterval.DateMonth;
fieldMonth.Caption = "Month";
See Also