PV table | undistinct count for the grand total with distinct count for the value

底部的总计应该只对列上的值求和,而右侧的总计应该只对行上的值求和。它不应该再考虑不同的计数,因为每行中的值已经具有不同的计数。

image-2022-01-06-14-19-45-330.png


1 Reply

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team September 23, 2022 01:38 PM UTC

Hi Joy,


We would like to inform that while using “Distinct count” aggregation type, the grand total also shows the distinct count value of respective columns and rows in the pivot table. This is the pivot table's default behavior. Microsoft Excel behaves similarly, and we followed the Microsoft Excel's approach. However, using aggregateCellInfo event, you can customize the cell value based on your needs. Please refer the below code example and screenshot.


Code Example:

aggregateCellInfo: function(args){

      if(args.fieldName == 'Sold'){

        if (args.columnCellType !== 'grandTotal') {

            rowVal += args.value;

          }

          if (

            args.columnCellType == 'grandTotal' &&

            args.rowCellType !== 'grandTotal'

          ) {

            args.value = rowVal;

            rowVal = 0;

          }

          if (args.rowCellType == 'value') {

            if (args.column.ordinal == 1) {

              columnOrdinal1 += args.value;

            } else if (args.column.ordinal == 2) {

              columnOrdinal2 += args.value;

            } else if (args.column.ordinal == 3) {

              columnOrdinal3 += args.value;

            } else if (args.column.ordinal == 4 && args.columnCellType == 'value') {

              columnOrdinal4 += args.value;

            } else if (

              args.column.ordinal == 4 &&

              args.columnCellType == 'grandTotal'

            ) {

              columnGrandTotal += args.value;

            }

          }

          if (args.rowCellType == 'grandTotal') {

            if (args.column.ordinal == 1) {

              args.value = columnOrdinal1;

            } else if (args.column.ordinal == 2) {

              args.value = columnOrdinal2;

            } else if (args.column.ordinal == 3) {

              args.value = columnOrdinal3;

            } else if (args.column.ordinal == 4 && args.columnCellType == 'value') {

              args.value = columnOrdinal4;

            } else if (

              args.column.ordinal == 4 &&

              args.columnCellType == 'grandTotal'

            ) {

              args.value = columnGrandTotal;

            }

          }

      }

    }


Screenshot:

Meanwhile, we have prepared a sample for your reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/pivot-539205323


Also, please refer the document link for more information about “aggregateCellInfo” event.

Document: https://ej2.syncfusion.com/vue/documentation/pivotview/aggregation/#aggregatecellinfo


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.


Loader.
Up arrow icon