Hi
I need create one measure for total sales amount Proportion by product category. For Example:
column measure
Productcate , Productname salesamount amount%
A, A1 100, 58%
A, A2 50 29%
A, A3 20 11%
A subtotal 170 73%
B, B1 50 83%
B, B2 10 17%
b subtotal 60 27%
Total 230 100%
How to design this code function?
Thanks.
James
Hi James,
You can check the following four thread discussing the same topic:
https://www.telerik.com/forums/custom-measures-in-pivot-grid
https://www.telerik.com/forums/calculate-measures-in-a-pivotgrid
Regards,
Nikolay
Hi Nikolay,
Thanks for your help first. Could you please get me custom measure detail documents? Because we don't know how to set this sample.
.Aggregate("aggregateHandler").Result("resultHandler")
In my case calculate the sales-total values by column group. It is different from fields detail data.
Please kindly help this. Thanks
Regards,
James
Hi,
The relevant configuration of the Html Helper
.Aggregate("aggregateHandler").Result("resultHandler")
if the following:
measures: { "Anzahl": { field: "G30_KEY", aggregate: "sum" }, "Gewicht": { field: "G30_SACH_RECHTSGEBIET", aggregate: "sum" }, "Ratio": { field: "G30_SACH_RECHTSGEBIET", aggregate: function (value, state, context) { var dataItem = context.dataItem; var G30_SACH_RECHTSGEBIET = dataItem.G30_SACH_RECHTSGEBIET; var G30_KEY = dataItem.G30_KEY; // Manually aggregate the fields. state.G30_SACH_RECHTSGEBIET_SUM = ( state.G30_SACH_RECHTSGEBIET_SUM || 0 ) + G30_SACH_RECHTSGEBIET; state.G30_KEY_SUM = ( state.G30_KEY_SUM || 0 ) + G30_KEY; }, result: function (state) { return (state.G30_SACH_RECHTSGEBIET_SUM / state.G30_KEY_SUM).toFixed(2); } } }
Here is the runnable DOjo: https://dojo.telerik.com/ihegiqUq
Regards,
Nikolay