Looking at this thread: http://www.telerik.com/community/forums/silverlight/pivotgrid/custom-calculations.aspx I see how it is possible to add a custom Aggregation to a field at start up, but I don't see a way to integrate the custom aggregation function into the PivotFieldList's UI. Is there a way to do this?
8 Answers, 1 is accepted
We have worked really hard in order to give our users the ability to use Calculated Fields. That's why after implementing this functionality we have included it in our internal builds, which you are able to download under your account. I'm sending you a modified version of the mentioned project where calculated fields are used instead of the custom aggregate function. Please note that this example will work only with our latest internal builds - the latest official version doesn't have CaluclatedFields included in it.
By using our Calculated Fields you will see the item in the Field List and also you will reduce the amount of code that you have to write.
Hopefully this makes sense.
Regards,
Rosen Vladimirov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
By using the Index calculation you should achieve the desired. You can apply it from the UI by clicking on the selected aggregate value in the PivotFieldList and selecting the Index item (check the screenshot). You can achieve the same from XAML by using the following snippet:
<
pivot:LocalDataSourceProvider.AggregateDescriptions
>
<
pivot:PropertyAggregateDescription
PropertyName
=
"Net"
AggregateFunction
=
"Sum"
>
<
pivot:PropertyAggregateDescription.TotalFormat
>
<
pivot:Index
/>
</
pivot:PropertyAggregateDescription.TotalFormat
>
</
pivot:PropertyAggregateDescription
>
</
pivot:LocalDataSourceProvider.AggregateDescriptions
>
http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/features/localdatasourceprovider/calculations.html#calculations
Regarding the creation of custom aggregate description - we have a great example demonstrating how to achieve that in our QSF demos - http://demos.telerik.com/wpf/ - example "Custom Aggregate Description"
Regards,
Polya
Telerik
Mine is WinForms app. I tried using the WPF sample and it somewhat worked for SQRT. Hhowever, I don't see how I can make it work for Weighted average calculation. Weighted average requires keeping aggregated value for some extra auxiliary field. For example, you can find weighted average interest rate by unpaid balance. Field names are not hardcoded in my application and really user should be able to specify field value and field weight component.
Also, How does the custom aggregation function appear in PivotFieldList? I see that WPF sample shows SQRT in the available function list. I could not do the same in sample WinForms app i am playing with.
Add to my last post, I need something similar to what this guy is trying to do here in the link below. My problem is that I can't really add a pre-calculated field for Product Sum in my datasource because i don't know which field user would select at run time.
http://www.telerik.com/forums/weighted-average
Any help would be greatly appreciated.
Dhairya
With the current implementation of RadPivotGrid the proposed approach in the thread you mentioned is the only way to achieve the desired.
You would need to create a custom CalculatedField and use the added predefined columns with the product calculations from the database.
Regards,
Polya
Telerik
I find our customers need access to weighted averages in building a pivot table as well (end user needs to control which column is being weighted by).
Are there any plans to add necessary infrastructure to allow a weighted average to be included in a way that allows users to select and configure it from the PivotFieldList's dialogs?
I suggest creating a feature request in our Feedback Portal: http://feedback.telerik.com/Project/143 from where you can track the progress of the feature and vote for it.
Regards,
Polya
Telerik