We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Axis Specific Aggregates or Custom Aggregate Override

Hello:

I'm working on satisfying a requirement using the Javascript PivotView.  I need to display different aggregates on each axis for a given value.  Ideally, I would be able to explicitly define an aggregate for each value by axis, but I'm not sure I'm able to do that with this control.

For Example, the below pivot showcases my desired outcome:

Example ABCExample DEFExample GHIGrand Totals (Averages)

TotalTotalTotalTotal
Example 1232464
Example 4565555
Grand Totals (Summation)79119

Currently, I have each value set to average, so i only need to "override" the aggregates at the bottom to reflect a summation.  I'm hoping I can "override" the values either in an event (load, enginePopulating, enginePopulated, dataBound, ...) or in a cellTemplate.

I appreciate any suggestions or advice in achieving the desired functionality.


Thanks


3 Replies

SA Scintilla Arul Jothi Raj Syncfusion Team August 20, 2019 01:18 PM UTC

Hi Doug, 

Thanks for contacting Syncfusion support. Please find the response below. 

We have validated your query and it is not an appropriate behavior for pivot table control. Meanwhile, you can achieve your requirement manually in “enginePopulated” event. Please find the following code snippet for your reference. 

Code snippet: [JavaScript] 
enginePopulated: function(args) { 
          var sumValue =0, count =0; 
           
          for(var i=0; i<args.pivotValues.length; i++){ 
            for(var j=0; j<args.pivotValues.length; j++){ 
              debugger 
              if(args.pivotValues[i][j]!= undefined && args.pivotValues[i][j].axis == "column" && args.pivotValues[i][j].formattedText != "Grand Total") 
               count++; 
              if(args.pivotValues[i][j]!= undefined && args.pivotValues[i][j].axis == "value"){ 
                if(j==(args.pivotValues.length-1)) 
                   args.pivotValues[i][j].value=args.pivotValues[i][j].formattedText = sumValue/count;  

                else 
                   sumValue += args.pivotValues[i][j].value; 
             
           
            sumValue =0; 
         
                
        } 
 
 
Please let us know if you have any concerns. 

Regards, 
Scintilla A 



DL Doug Lenos August 20, 2019 03:17 PM UTC

This works perfect!  Thanks for the speedy reply.


SA Scintilla Arul Jothi Raj Syncfusion Team August 21, 2019 04:41 AM UTC

Hi Doug, 
Thanks for the update. Please let us know if you need any further assistance. 
  
Regards, 
Scintilla A 


Loader.
Live Chat Icon For mobile
Up arrow icon