title: Can I group DateTime type data in PivotGrid of DevExpress during runtime?
body: <p>I have a PivotGrid (DevExpress) within WPF and bind the DataSource to an IList that contains objects of which there are several properties of type DateTime. I want the end-user to choose during runtime which of those DateTime fields the user wants to group by Year, Month, or Day. Is that possible?</p>
  
  <p>I understand that I can provide DateTime groupings programmatically but as there are several DateTime fields it would be quite tedious and unnecessary if the end-user can choose which DateTime field to group and how to group it during runtime. </p>
  
  <p>Can you please guide me how to do that? </p>
  
  <p>I have the following:</p>
  
  <pre><code>  &lt;dxdo:LayoutControlItem ItemWidth="1*"&gt;
                                  &lt;dxpg:PivotGridControl MaxHeight="800" MaxWidth="800" DataSource="{Binding AllChildOrders}" DataSourceChanged="PivotGridControl_OnDataSourceChanged"&gt;
                              &lt;/dxpg:PivotGridControl&gt;
                          &lt;/dxdo:LayoutControlItem&gt;
  </code></pre>
  
  <p>and in code behind:</p>
  
  <pre><code>private void PivotGridControl_OnDataSourceChanged(object sender, RoutedEventArgs e)
      {
          var pivotTable = sender as PivotGridControl;
          pivotTable.RetrieveFields();
      }
  </code></pre>
  
  <p>The above code works and the pivot table displays all available fields during runtime, including the fields of type DateTime. I do not want to programmatically specify which fields to group in particular ways but let the end-user during runtime choose how and which field to group. Possible?</p>
  
  <p>Alternatively I could imagine to programmatically create sub-groupings as follows: How can I accomplish the following?</p>
  
  <p><img src="https://i.stack.imgur.com/FAcfz.jpg" alt="enter image description here"></p>