Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Crystal Reports - Suppress field when counter > 2

Posted on 2014-08-12
8
Medium Priority
?
2,160 Views
Last Modified: 2014-08-12
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.
0
Comment
Question by:nightshadz
  • 5
  • 3
8 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40255620
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
 

Author Comment

by:nightshadz
ID: 40255674
I'm pretty new to crystal reports so this is somewhat confusing to me. Can you explain please?
0
 

Author Comment

by:nightshadz
ID: 40255719
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

 
LVL 101

Expert Comment

by:mlmcc
ID: 40255896
Reset it to false in the group header or footer

mlmcc
0
 

Author Comment

by:nightshadz
ID: 40256441
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
 

Author Comment

by:nightshadz
ID: 40256477
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
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 40257068
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
 

Author Closing Comment

by:nightshadz
ID: 40257135
Got it that worked! Thanks for all the assistance!
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question