How to sum running total field for each group in crystal report?

旧城冷巷雨未停 提交于 2019-12-23 04:42:10

问题


i have problem in crystall report,

Here is my code following many reference site in google,

// {@reset}
//place in group header
whileprintingrecords;
global numbervar Sum_Cumm_Sum:=0;

// {@increment}
//place in section detail
whileprintingrecords;
global numbervar Sum_Cumm_Sum:=Sum_Cumm_Sum+{@getIP};

// {@display}
//place in group footer
whileprintingrecords;
global numbervar Sum_Cumm_Sum;

Where getIP is Formula,

{#sumKN}/{#sumSKS}

and code in it is running total field with reset on change group,

{#sumKN} is running total field for field KN 
{#sumSKS} = is running total field for field SKS

============================================================

I use all this code, but in Sum_Cumm_Sum:=Sum_Cumm_Sum+{@getIP}, I can't get the right value.

Here is my report view:

http://i.stack.imgur.com/CSmsB.png


回答1:


To the extent I see as you placed in detail section your formula is working correctly, Now you want to see the summation of values in footer then you need to write saperate formula to sum index.... in footer section so that it sumarizes it saperatley.




回答2:


Either use a manual running total OR a running-total field, not both. By the way, a running-total field only works in a footer section.

A better approach:

{#sumKN} - field is {table.KN}; summarize for all records; reset after change in group

{#sumSKS} - field is {table.SKS}; summarize for all records; reset after change in group

// place in `footer` section
//{@ratio}

// optional
// EvaluateAfter({#sumKN});
// EvaluateAfter({#sumSKS});

{#sumKN} / {#sumSKS}


来源:https://stackoverflow.com/questions/21775371/how-to-sum-running-total-field-for-each-group-in-crystal-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!