Dates values

12 posts, 0 answers
  1. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 07 Feb 2018 Link to this post

    Hello, I should introduce Dates values in a pivot, with the possibility to find min and max values. Is it possible? Thanks in advance,
    best regards
  2. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 12 Feb 2018 Link to this post

    Hello Stefania,

    RadPivotGrid can be grouped by dates - the properties of type DateTime will automatically shown in RadPivotFieldList, so you can easily group by them using drag and drop. For more details on how to use the DateTimeGroupDescription, please check the following article from our online help documentation:
    https://docs.telerik.com/devtools/wpf/controls/radpivotgrid/features/localdatasourceprovider/datetimegroupdescription

    As for min and max - could you please share more details on the exact scenario you need to achieve? In RadPivotFieldList you could filter the dates as desired using Label Filter.

    You could also check the PivotGrid demos in our WPF samples application - please let me know if you have any other questions.

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 12 Feb 2018 in reply to Kalin Link to this post

    Example in the Pivot grid with PivotFieldList demo.

    I remove Sum Of Quantities from aggregates. Drag Date into aggregates and then show Max(Dates) into the grid (instead of sum quantities).

  4. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 15 Feb 2018 Link to this post

    Hi Stefania,

    Thanks for the further details. With the current implementation there aren't built-in DateTime aggregate functions. However you should be able to achieve the same by implementing a custom aggregate function as demonstrated in the Custom Aggregate Description example from our demos (this Silverlight link, however the demo is identical for WPF):
    https://demos.telerik.com/silverlight/#PivotGrid/CustomAggregateDescription

    I'm preparing WPF demo demonstrating the approach - will get back to you when I'm done.

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 20 Feb 2018 Link to this post

    Hi Stefania,

    I'm attaching sample project demonstrating how to implement a custom MaxDate aggregate function.

    Hope this helps.

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  6. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 20 Feb 2018 in reply to Kalin Link to this post

    Ok, it works, thank you.

    I have already edit it to manage also datetime?  and added functions Min and Average.

    There is only a not correct behaviour

    In the demo, in MainWindow.xaml remove this code

    <!--<pivot:LocalDataSourceProvider.AggregateDescriptions>
                  <local:MaxDateAggregateDescription PropertyName="Date">
                      <local:MaxDateAggregateDescription.AggregateFunction>
                          <local:MaxDateAggregateFunction />
                      </local:MaxDateAggregateDescription.AggregateFunction>
                  </local:MaxDateAggregateDescription>
              </pivot:LocalDataSourceProvider.AggregateDescriptions>-->

    Now the application start with no aggregates. If I add Date to aggregates by default it use Sum aggregation and pivot values is Error.

    Than I can change to count or max ecc... and it works

    How can I fix it?

  7. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 22 Feb 2018 Link to this post

    Hi Stefania,

    The reason for this behavior is that the MaxDateAggregateDescription uses Sum function by default, so for this scenario we would have change the AggregateFunction property as well (as it is done in MainWindow.xaml). This can be done for example in the constructor of the MaxDateAggreagateDescription class:

    public MaxDateAggregateDescription()
    {
        this.AggregateFunction = new MaxDateAggregateFunction();
    }

    Please give it a try and let me know if you have any other questions.

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  8. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 26 Feb 2018 in reply to Kalin Link to this post

    Ok, it works.

    Thank you.

  9. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 28 Mar 2018 Link to this post

    Hi,

    How can I set the date cells alignment to center?

  10. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 30 Mar 2018 Link to this post

    Hello Stefania,

    You should be able to change the alignment by applying a custom header or cell template - prepare a DataTemplate with TextBlock aligned as desired and apply it to the needed headers or cell. Please refer to the following article:
    https://docs.telerik.com/devtools/wpf/controls/radpivotgrid/styles-and-templates/templating-cells

    Let me know if you have any further questions or concerns.

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  11. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 03 Apr 2018 Link to this post

    Hi,

    in the example it use description.PropertyName to check the property info.

    I would like to create a more generic function. Is it possible to check the DataType property of PivotFieldInfo?

  12. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 05 Apr 2018 Link to this post

    Hi Stefania,

    The PropertyAggregateDescriptionBase class has protected DataType property, so for the custom MaxDateAggregateDescription discussed in the previous posts this property can be easily exposed and checked afterwards in the CellTemplateSelector. Or you could simply check the custom aggregate description.

    Let me know if this helps. Do you want to change the appearance of the header cells as well?

    Regards,
    Kalin
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top