- Home
- Forum
- JavaScript - EJ 2
- Axis Specific Aggregates or Custom Aggregate Override
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 ABC | Example DEF | Example GHI | Grand Totals (Averages) | |
| Total | Total | Total | Total | |
| Example 123 | 2 | 4 | 6 | 4 |
| Example 456 | 5 | 5 | 5 | 5 |
| Grand Totals (Summation) | 7 | 9 | 11 | 9 |
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
SIGN IN To post a reply.
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;
}
} |
Sample link: https://stackblitz.com/edit/cczntf?file=index.js
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
DL Doug Lenos
- Aug 19, 2019 07:38 PM UTC
- Aug 21, 2019 04:41 AM UTC