Total Count in Crystal

Hello experts -

I am trying to do a conditional count in Crytal Reports but am having trouble with the first record not being counted since I am using the 'previous' command.  Below is what I have in the details section of the report:

WhilePrintingRecords;
Global NumberVar TotalAlumni;
if {gifts_VIEW_ngp.giftid}<>previous({gifts_VIEW_ngp.giftid})
and {gifts_VIEW_ngp.coreconst}=["a","h"]
then TotalAlumni := TotalAlumni+1
else 0

Then I also have a formula in the footer to show the total as follows:

WhilePrintingRecords;
Global NumberVar TotalAlumni;
if {@Alumni Gifts Count}=0
then
TotalAlumni
else
TotalAlumni+1

I tried to add the missing record (TotalAlumni+1) which works fine unless the first record listed is not an alumni record, then a record is added that should not be.

I tried to figure out a way to use the recordnumber command but didn't get very far (something like 'if recordnumber =1 and {gifts_VIEW_ngp.coreconst}<>["a","h"] then TotalAlumni')

As always, any and all assistance is very much appreciated!

Lisa

lcallah93Asked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
Try it this way

WhilePrintingRecords;
Global NumberVar TotalAlumni;
if (OnFirstRecord OR ({gifts_VIEW_ngp.giftid}<>previous({gifts_VIEW_ngp.giftid})))
and {gifts_VIEW_ngp.coreconst}=["a","h"]
then TotalAlumni := TotalAlumni+1
else 0

mlmcc
0
 
lcallah93Author Commented:
Thank you!  That is exactly what I needed!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.