Adding computed values to a pivot table

I am evaluating your pivot table; I’ve updated one of your samples (http://docs.webix.com/samples/61_pivot/01_init/01_inline_data.html) and start playing with it.

I’ve added my source data, updated the configuration of the widget, run the sample locally, and I get the expected result.

It is basically a sales report where rows contain product brands and categories, and columns sum up sales (amount and quantity) by year (current and previous year). Nothing really new so far.

Next request was to display, for each row, the difference (as a perecentage) for amounts and quantity between the current year and the previous one.

Is it possible to get this result?

TIA

You can add columns and apply math calculation for them:

Here is the demo:

http://webix.com/snippet/552d14a9

Maria
Thank you for your fast answer!
I will try it soon.

Worked like a charm!
Thanks again

One last suggestion: if I set a filter, the added columns are lost; I suppose I should re-run the code to define the new columns again. If so, which event should I attach an handler to?

What should I set to drop the name of the operation from the column text?

Yes, applying filters will redraw pivot. We are going to add onHeaderInit event that will allows to customize columns.

The existent version will require more complicated solution:

  • enable “totalColumn” for your pivot to add columns. These new columns apply sum calculation, but it is possible to change their math template;
  • set onBeforeRender event handler to DataTable of Pivot. There you will need to iterate over “columns” array to exclude (sum) from header text and math calculation for last 2 columns.

http://webix.com/snippet/9090e68b

Math calculations in pivot table in version 5.2 not working - example for 5.2 http://webix.com/snippet/9090e68b and example for 5.1 https://snippet.webix.com/pqx9a86a

Please update to the latest Webix 5.2.3, it contains a fix for this regression.