Solved

Crystal Reports 8.5. Suppressing non consecutive duplicate fields

Posted on 2004-08-04
4
793 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
ID: 11722542
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
ID: 11722836
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
ID: 11725520
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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. …
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

19 Experts available now in Live!

Get 1:1 Help Now