CALCULATED FIELDS

5 posts, 0 answers
  1. hamish
    hamish avatar
    44 posts
    Member since:
    Jun 2007

    Posted 12 Sep 2014 Link to this post

    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>();
  2. Polya
    Admin
    Polya avatar
    199 posts

    Posted 15 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Arnaud
    Arnaud avatar
    17 posts
    Member since:
    Mar 2013

    Posted 14 Mar Link to this post

    I'm in the exact same scenario. Is the any workaround for this ?
  5. Polya
    Admin
    Polya avatar
    199 posts

    Posted 15 Mar Link to this post

    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.
  6. Arnaud
    Arnaud avatar
    17 posts
    Member since:
    Mar 2013

    Posted 15 Mar in reply to Polya Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready