Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Totals Problem 2

Status
Not open for further replies.

JCook23

Technical User
May 19, 2004
39
US
I have two formulas that I need to do running totals:

1) @RemainingQuantity
2) @Ext

I have the following formulas for the first (@RemainingQuantity):

@SetManSum: (Suppressed in the Group Header)
WhilePrintingRecords;
NumberVar Mansum;
Mansum:= 0;

@GetManSum: (Suppressed in the Details)
WhilePrintingRecords;
NumberVar Mansum;
If{poitem.forgpdate} = {poitem.flstpdate} then
Mansum:= Mansum + {@Rem Qty} else ManSum;

@DisplayManSum: (In the Group Footer)
WhilePrintingRecords;
NumberVar Mansum;
Mansum;

Then I created the following for the @Ext:

@SetManSum2: (Suppressed in the Group Header)
WhilePrintingRecords;
NumberVar Mansum;
Mansum:= 0;

@GetManSum2: (Suppressed in the Details)
WhilePrintingRecords;
NumberVar Mansum;
If{poitem.forgpdate} = {poitem.flstpdate} then
Mansum:= Mansum + {@Ext} else ManSum;

@DisplayManSum2: (In the Group Footer)
WhilePrintingRecords;
NumberVar Mansum;
Mansum;

If I have both sets in the report they both return the total for the @ext. If I only have the three for the @Remaining Quantity, it returns the correct total.

I am using CR10.0 with SQLServer.

Thanks!

Jeff
 
Consider using Running Totals which reset at the group level and have the following in the Evaluate->Use a formula:

{poitem.forgpdate} = {poitem.flstpdate}

Since you didn't share what's in the formulas these are based on, it's hard to know whether this will work for you:

1) @RemainingQuantity
2) @Ext

Please include all required formulas.

To make sure that you can do this, your formulas should always return a value, such as:

if <condition> then
1
else
0

Then these can be summarized by the running totals.

-k
 
The other thing that can cause a problem is if the Group header section is repeated on a subsequent page. This will reset the accumulators. Fix this with....

@SetManSum: (Suppressed in the Group Header)
WhilePrintingRecords;
NumberVar Mansum;
if not InRepeatedGroupHeader then Mansum:= 0;


Editor and Publisher of Crystal Clear
 
@RemainingQuantity:

{poitem.fordqty} - {poitem.frcpqty}

@Ext:

{@Rem Qty} * {poitem.fucost}

The Group Header does not repeat for each page. Thanks for all your input and any other thoughts you may have.....

Jeff C.

 
Why are you using the same variable name in both formulas?
Of course they will return the same thing.
Change one of the variable names.



Bob Suruncle
 
Bob,

Thank you for shooting me and putting me out of my misery! Sometimes the obvious is hard to spot!

Thanks again,

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top