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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lcallah93Author Commented:
Thank you!  That is exactly what I needed!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.