Solved

Crystal Reports 8.5. Suppressing non consecutive duplicate fields

Posted on 2004-08-04
4
794 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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