Skip to main content

How to: Group Date-Time Values

This example shows how to group date-time values.

View Example

Multiple Pivot Grid fields are bound to the same data field - OrderDate. The DataSourceColumnBindingBase.GroupInterval property is used to create a Year → Quarter → Month hierarchy.

Group date-time values

<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" 
    DataSourceID="SqlDataSource1" ClientIDMode="AutoID" IsMaterialDesign="False" 
    OptionsView-RowTotalsLocation="Tree">
    <Fields>
        <dx:PivotGridField ID="fieldSales" Area="DataArea" AreaIndex="0" Name="fieldSales">
            <DataBindingSerializable>
                <dx:DataSourceColumnBinding ColumnName="ExtendedPrice" />
            </DataBindingSerializable>
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldYear" Area="RowArea" Caption="Year" Name="fieldYear" AreaIndex="0">
            <DataBindingSerializable>
                <dx:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateYear" />
            </DataBindingSerializable>
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldQuarter" Area="RowArea" Caption="Quarter" Name="fieldQuarter" AreaIndex="1">
            <DataBindingSerializable>
                <dx:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateQuarter" />
            </DataBindingSerializable>
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldMonth" Area="RowArea" AreaIndex="2" Name="fieldMonth" Caption="Month">
            <DataBindingSerializable>
                <dx:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateMonth" />
            </DataBindingSerializable>
        </dx:PivotGridField>
    </Fields>

    <OptionsView RowTotalsLocation="Tree"></OptionsView>
    <OptionsData DataProcessingEngine="Optimized" />
</dx:ASPxPivotGrid>