This is a migrated thread and some comments may be shown as answers.

Dates values

11 Answers 96 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Stefania
Top achievements
Rank 2
Stefania asked on 07 Feb 2018, 09:23 AM
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

11 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 12 Feb 2018, 09:16 AM
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.
0
Stefania
Top achievements
Rank 2
answered on 12 Feb 2018, 09:44 AM

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).

0
Kalin
Telerik team
answered on 15 Feb 2018, 08:23 AM
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.
0
Kalin
Telerik team
answered on 20 Feb 2018, 12:15 PM
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.
0
Stefania
Top achievements
Rank 2
answered on 20 Feb 2018, 03:21 PM

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?

0
Kalin
Telerik team
answered on 22 Feb 2018, 11:08 AM
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.
0
Stefania
Top achievements
Rank 2
answered on 26 Feb 2018, 10:44 AM

Ok, it works.

Thank you.

0
Stefania
Top achievements
Rank 2
answered on 28 Mar 2018, 12:53 PM

Hi,

How can I set the date cells alignment to center?

0
Kalin
Telerik team
answered on 30 Mar 2018, 11:04 AM
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.
0
Stefania
Top achievements
Rank 2
answered on 03 Apr 2018, 08:30 AM

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?

0
Kalin
Telerik team
answered on 05 Apr 2018, 08:47 AM
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.
Tags
PivotGrid
Asked by
Stefania
Top achievements
Rank 2
Answers by
Kalin
Telerik team
Stefania
Top achievements
Rank 2
Share this question
or