Results 1 to 2 of 2

Thread: Pivot Custom Aggregate Function returns NaN [fiddle]

  1. #1
    Sencha Premium Member
    Join Date
    Dec 2012
    Location
    Seattle, WA
    Posts
    423
    Answers
    34

    Default Answered: Pivot Custom Aggregate Function returns NaN [fiddle]

    I don't understand why this pivot custom aggregate function is returning NaN. All the columns sum correctly and in my function I am dividing group1 by group7 which should be 1 / 1 = 1 but instead returns NaN.

    Here is the fiddle https://fiddle.sencha.com/#view/editor&fiddle/2pbj

    I would appreciate any help with this.

  2. I think you need to add the records:

    Code:
    const sum = (arr, field) => arr.reduce((total, r) => total + r.get(field), 0);
    // 
    aggregator : function(records){
        return sum(records, 'group1') / sum(records, 'group7') * 100;
    }

  3. #2
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    I think you need to add the records:

    Code:
    const sum = (arr, field) => arr.reduce((total, r) => total + r.get(field), 0);
    // 
    aggregator : function(records){
        return sum(records, 'group1') / sum(records, 'group7') * 100;
    }

Similar Threads

  1. Replies: 0
    Last Post: 9 May 2018, 4:34 AM
  2. extjs pivot grid moving aggregate labels to row labels
    By solarissf in forum Ext JS 6.x Q&A
    Replies: 0
    Last Post: 29 Nov 2017, 1:00 PM
  3. Replies: 9
    Last Post: 9 Oct 2017, 3:28 AM
  4. Custom Aggregate function on multiple measures in pivot grid
    By highradius in forum Sencha Ext JS Q&A
    Replies: 0
    Last Post: 3 Oct 2017, 10:02 PM
  5. How do I use pivot grid in Fiddle
    By MikeRH in forum Sencha Fiddle
    Replies: 3
    Last Post: 16 Aug 2016, 6:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •