How to sum running total field for each group in c

2019-06-10 23:19发布

问题:

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}