How to define a custom function to calculate ratio in pivot table

In pivot table, for example, for each country name, I want to calculate the percentage of gdp to the total gdp of the country form.

The gdp of the certain country name (for example “Argentina”) can be obtained using sum, let’s say it is 181.357. the gdp of the certain country form (for example “Republic”) can be obtained using sum also, let’s say it is 24451.987. How could I obtain the percentage of gdp of “Republic” that belongs to “Argentina”?

ie For Argentina, we calculate 181.357/24451.987=0.74%
For China, we calculate 2256.919/24451.987=9.23%

Example source:

http://pivot.webix.com/samples/01_init/04_define_function.html

I think this should be one of the supplied value function other than sum, min,max,count, surprised nobody requested this yet.

Please advise how this can be done if I had to do it myself. This seems to need to retrieve data from a the higher aggregation level (country form level) which is not available in data parameter of custom function (at aggregation level country name).

Yes, you are right.
Currently there is no way to create a custom function with such kind of aggregation logic
We will add such feature in the next version ( custom operations will have access to all previously calculated data for the same row )

Was this ever implemented? I’m running into the same need right now where I have a boolean indicator if someone was responsible for an event or not, and I need to get a percentage of the events a given person was responsible for.

Events are rows in the underlying data table and the likeness of a “WasResponsible” is 1 or 0 accordingly.

No, sorry. Data of parent rows are not available in calculation functions. The next update will provide onBeforeRender event. Event will be fired after all pivot calculations and allow to customize table configuration and data.