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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group footer of cumulative variable not working

Status
Not open for further replies.

lab00

MIS
Nov 19, 2003
8
US
I am using Crystal 10. I have created a report to count the volume of a certain procedure by month, displayed in a row:

2010 Jan Feb March .....Dec
10 15 12 20

My report is grouped by Month (which is taken from the "case_date")

In my detail section, I have created a counter for each month to count "case numbers" ( there can be duplicate rows and I only want them counted once):

*********
whileprintingrecords;
numberVar JanCounter;

JanCounter:=
if {@Month}=1
and (onfirstrecord
or ({case_number}<>previous({case_number})))
then JanCounter:=JanCounter+1
else JanCounter:=JanCounter
*********
I initialize JanCounter in the Month group header.

This gives me:

Case number JanCounter
10045 1
10045 1
10322 2
10523 3

I then have another variable JanuarySubtotal
which I place in the Group footer.
*******************
whileprintingrecords;
numbervar JanSubtotal;
JanSubtotal:={@JanCounter}
********************

This works fine except for the last month in the report. It is adding one more to the last month's total. So if I run the report through June 30, the June total is 1 more than it should be. If I run it through Dec 15, Dec is 1 more than it should be.

Can somebody help me please?????
 
You should only be using the following to display results:

whileprintingrecords;
numbervar JanSubtotal;

When you reference the accumulation formula you are causing it to execute again, adding 1 to your result.

-LB
 
I am missing something here I think. Where do I tell it what "JanSubtotal" is? If I just put in the above code:
*****
whileprintingrecords;
numbervar JanSubtotal;
*****
it just gives me 0.

Sorry if I'm missing something obvious here but I have gone about as far as my limited knowledge will take me on this.
 
Sorry, I didn't notice you had created a separate variable (no need for one):

whileprintingrecords;
numbervar JanCounter;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top