Pivot custom operation for subtotal rows, footer total row, and total column

Hi there!
Can you give me a hint what would be the best way to implement custom operation for subtotal rows, footer total row, and total column? I need to display data in every other cell as sum, but for subtotals and totals it should be a count.
Thank you

I guess I was able to achieve something close to what I need with this code:

            pivot.operations.custom = function(args, i, t) {
                if (t.$source){
                    // cells
                    return pivot.operations.sum(args);
                } else if (t.data){
                    // subtotals
                    return args.length;
                } else {
                    // footer
                    return pivot.operations.sum(args);
                }

But I can’t hook up to totalColumn. Can you help me with that?

Hello,

You need to provide specific same-titled operation via addTotalOperation. Please note that this method will define an operation for both footers and total columns.

As the first argument, total operation receives values of all columns in a row, so AFAICS your operation can be simply reduced to

pivot.addTotalOperation("custom", function(args) {    
  // subtotals/cells/footer (sum of all values in row)
  return pivot.operations.sum(args);  
});

https://snippet.webix.com/dt4weiba

Kind regards,

By the way, this information was missing in the documentation - sorry for that. We have updated the corresponding docs chapter.

Many thanks for your help Listopad!

Any clue how to do this in version 9.1 ?