Crystal Reports - Suppress field when counter > 2

Hi,

I have a counter set up to count the number times "xyz" appears in a field. The counter displays like this in the details section and here is how I need to suppress the field when a certain condition is met:

0
0
1  xyz
1
1
2  xyz
2 (suppress this record and all records below)
3
3

If my formula is suppress when > 2, it will still display all records until the third occurrence. I'm not sure how to set this up.
nightshadzAsked:
Who is Participating?
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 this.

Change your suppression formula to do the counting.  You won't need the other formula

Suppression Formula
WhilePrintingRecords;
Global NumberVar counter;
Global BooleanVar SuppressMe;

SuppressMe := counter >= 2;
If {Field} = 'xyz' then
    counter := counter + 1;
SuppressMe 

Open in new window


You could do a similar thing in your counting formula

Counting formula
WhilePrintingRecords;
Global NumberVar counter;
Global BooleanVar SuppressMe;

SuppressMe := counter >= 2;
If {Field} = 'xyz' then
    counter := counter + 1;
counter

Open in new window


Suppression formula
WhilePrintingRecords;
Global BooleanVar SuppressMe;

SuppressMe
 

Open in new window


mlmcc
0
nightshadzAuthor Commented:
I'm pretty new to crystal reports so this is somewhat confusing to me. Can you explain please?
0
nightshadzAuthor Commented:
Ok, I put the Suppression Formula in a new variable and for the first group it works, but the rest of the records for the remainder of the dataset show false. I'll need to play around with this a bit. I'll keep you updated.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

mlmccCommented:
Reset it to false in the group header or footer

mlmcc
0
nightshadzAuthor Commented:
I put this in a Formula Field and added it to the detail. It displays False until the row following the 2nd 'Promotion', then it displays True.

WhilePrintingRecords;
Global NumberVar counter;
Global BooleanVar suppressMe;
Global StringVar gName;

suppressMe := counter >= 2;
If {@ActionReason} = 'Promotion' then
    counter := counter + 1;

suppressMe 

Open in new window


I have a group header suppressed and I'm not sure where in the group header I would set this to False?
0
nightshadzAuthor Commented:
I tried creating a new Formula Field to set counter = 0 to place in the group header but I can't get it to save so I'm doing something wrong. ;)
0
mlmccCommented:
The formula to reset it would be

WhilePrintingRecords;
Global NumberVar counter;
counter := 0;
''

Open in new window


I would then unsuppress the group header since formulas tend not the evaluate if the section is suppressed.

If you need it suppressed then suppress it with a formula that always evaluates to true or make sure nothing is displayed and suppress it with the SUPPRESS BLANK SECTION option in the section expert.

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
nightshadzAuthor Commented:
Got it that worked! Thanks for all the assistance!
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.

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.