How to sum running total field for each group in c

2019-06-10 23:29发布

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

2条回答
迷人小祖宗
2楼-- · 2019-06-11 00:13

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}
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-11 00:16

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.

查看更多
登录 后发表回答