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

CALCULATED FIELDS

4 Answers 74 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
hamish
Top achievements
Rank 1
hamish asked on 12 Sep 2014, 04:37 PM
I have created a class for calculated fields and all works as expected. However where I am having a problem is where I am using something OTHER than a field that is 'summed'. For example I have a column called "Fill Price" which is the total of a x number of fill prices on stock trades. In the pivot grid I want to show the Average Fill Price so I select the option "Average" as the calculation option in the Field List. Again this gives me the desired answer in this column in the pivot grid, however when I go to use that field (Fill Price) in the calculated field it gives me the Total and NOT the Average. The following code is how I get the field in my concrete class for the calculated field however in this case the value in the field titled dbl is the Total fill Price and not the average as I was expecting. How do I get at the Average value?

Thank you
AggregateValue agg = aggregateValues.GetAggregateValue("fill Price");
double dbl = agg.ConvertOrDefault<double>();

4 Answers, 1 is accepted

Sort by
0
Polya
Telerik team
answered on 15 Sep 2014, 11:56 AM
Hi Hamish,

By design the RadPivotGrid uses a SumAggregate when getting the aggregated value of the RequiredField in a custom CalculatedField and an override of this behavior is currently not available.

However, we have this feature request logged in our Feedback portal, where you can track its status and vote to raise its priority:
http://feedback.telerik.com/Project/143/Feedback/Details/136167-provide-an-option-to-change-the-aggregate-function-of-the-requiredfield-in-a-cust.

Regards,
Polya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Arnaud
Top achievements
Rank 1
answered on 14 Mar 2016, 12:39 PM
I'm in the exact same scenario. Is the any workaround for this ?
0
Polya
Telerik team
answered on 15 Mar 2016, 02:09 PM
Hello Arnaud,

With our current implementation of RadPivotGrid there is no workaround for this behavior.
You can follow and vote for the Feedback Item in our portal:
http://feedback.telerik.com/Project/143/Feedback/Details/136167-provide-an-option-to-change-the-aggregate-function-of-the-requiredfield-in-a-cust

Regards,
Polya
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Arnaud
Top achievements
Rank 1
answered on 15 Mar 2016, 02:19 PM

For people reading this:

I manage to get an average value in CalculatedField by providing an additional ReqiredField based on a dedicated property used for counting. In my model I used a read-only property that just return 1. The aggregated value (SumAggregate) gives the total number of items, then you just have to divide.

Note: the total number of item could not be retrieved directly because actual implementation of IAggregateValues and IGroup are not accessible. PivotGrid is good but full of such limitations !

 

Regards,

Arnaud.

Tags
PivotGrid
Asked by
hamish
Top achievements
Rank 1
Answers by
Polya
Telerik team
Arnaud
Top achievements
Rank 1
Share this question
or