Solved

Crystal Reports 8.5. Suppressing non consecutive duplicate fields

Posted on 2004-08-04
4
792 Views
Last Modified: 2009-07-29
How do i suppress duplicates within a report if those duplicates are not consecutivly listed. (for consecutively listed reports I can use either the suppress duplicates checkbox for the field or use a Previous field formula.
E.g. Report with 3 fields    A          B          C    
    Brings back                  (A1)     (B1)      (C1)
                                      (A1)     (B1)       (C2)
                                      (A1)     (B1)       (C3)
                                      (A1)     (B2)       (C1)
                                      (A1)     (B2)       (C4)
                                      (A2)     (B3)       (C1)
                                      (A2)     (B2)        (C3)
I would like to only display each return once so that report above looks like
                                      A          B          C    
    Brings back                  (A1)     (B1)      (C1)
                                                              (C2)
                                                              (C3)
                                                 (B2)      
                                                               (C4)
                                      (A2)     (B3)        
                                               
Can I achieve this witha suppress field formula?
0
Comment
Question by:saylaugh
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
frodoman earned 250 total points
Comment Utility
You can probably do it, but it'll be messy.  I don't have access to Crystal at the moment so some syntax may be off but basically you want to write a formula that's really a mini-program...

//@InitFormula  <- Place in report header
shared numberVar NumDistinct := 0;
shared numberVar array FieldAList[100];   <- Assumes field A is numeric, use appropriate data type

//@SuppressFormula  <- Use to conditionally suppress field A.
numberVar i;
booleanVar DupEntry := false;
if shared numberVar NumDistinct = 0 then
(
   shared numberVar array FieldAList[1] := {table.fieldA}
   NumDistinct := 1;  
)
else
(
   for i = 1 to NumDistinct
   (
      if shared numberVar array FieldAList[i] = {table.fieldA} then DupEntry := true;
   )
   NumDistinct := NumDistinct + 1;
   FieldAList[NumDistinct] := {table.fieldA};
)
DupEntry;

Follow the same process for the other two fields and you should have them suppressed - as I said, it's messy...

frodoman
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Do you need the format as shown or will something like this work?

      A          B          C    
    (A1)     (B1)      (C1)
    (A2)     (B2)      (C2)
               (B3)       (C3)
                            (C4)

If so you could use subreports for each column and use the Select Distinct capability or suppress duplicate records.

mlmcc
0
 
LVL 42

Expert Comment

by:frodoman
Comment Utility
Also I didn't ask about your data source.  I believe the absolute best method would be to use a stored procedure and filter out the unnecessary date before it even gets to Crystal.

If you're already using a SP or have the option of doing so then I'd advise taking this route.

frodoman
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now