Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: GROUP Question Post Reply Post New Topic
Author Message
ViperSBT
Newbie
Newbie
Avatar

Joined: 02 Jul 2009
Location: United States
Online Status: Offline
Posts: 12
Quote ViperSBT Replybullet Topic: GROUP Question
     Posted: 06 Jul 2009 at 8:20am
If this is my report:
< ="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 11">< name="Originator" content="Microsoft Word 11"><>
    PartNu   PartDescription   TranType
032770                
    032770   BOLT SECURITY   ADJ-CST
    032770   BOLT SECURITY   ADJ-QTY
    032770   BOLT SECURITY   PUR-STK
    032770   BOLT SECURITY   STK-MTL
                 
032771                
    032771   BARREL SLIDE BOLT STAINLESS STEEL WITH NICKEL PLATED BRASS BOLT DULL FINISH
BOLT PLATE IS 2-3/8" X 15/16"
BOLT RECEIVER IS 13/16" X 15/16"
BOLT EXTENSION IS 19/32"
BOLT DIAMETER IS 1/4"
  ADJ-CST
    032771   BARREL SLIDE BOLT STAINLESS STEEL WITH NICKEL PLATED BRASS BOLT DULL FINISH
BOLT PLATE IS 2-3/8" X 15/16"
BOLT RECEIVER IS 13/16" X 15/16"
BOLT EXTENSION IS 19/32"
BOLT DIAMETER IS 1/4"
  ADJ-QTY
    032771   BARREL SLIDE BOLT STAINLESS STEEL WITH NICKEL PLATED BRASS BOLT DULL FINISH
BOLT PLATE IS 2-3/8" X 15/16"
BOLT RECEIVER IS 13/16" X 15/16"
BOLT EXTENSION IS 19/32"
BOLT DIAMETER IS 1/4"
  PUR-STK
    032771   BARREL SLIDE BOLT STAINLESS STEEL WITH NICKEL PLATED BRASS BOLT DULL FINISH
BOLT PLATE IS 2-3/8" X 15/16"
BOLT RECEIVER IS 13/16" X 15/16"
BOLT EXTENSION IS 19/32"
BOLT DIAMETER IS 1/4"
  STK-MTL
                 
032850                
    032850   SCREW TEK PHILLIPS PAN HEAD 10-16 X 1/2   ADJ-CST
    032850   SCREW TEK PHILLIPS PAN HEAD 10-16 X 1/2   ADJ-PUR
    032850   SCREW TEK PHILLIPS PAN HEAD 10-16 X 1/2   PUR-UKN
                 
032900                
    032900   SCREW TEK HEX HEAD ZINC 10-16 X 3/4   ADJ-CST
    032900   SCREW TEK HEX HEAD ZINC 10-16 X 3/4   ADJ-PUR
    032900   SCREW TEK HEX HEAD ZINC 10-16 X 3/4   PUR-UKN
                 
032940                
    032940   SCREW TEK PHILLIPS PAN HEAD 10-16 X 3/4   ADJ-CST
    032940   SCREW TEK PHILLIPS PAN HEAD 10-16 X 3/4   ADJ-PUR
    032940   SCREW TEK PHILLIPS PAN HEAD 10-16 X 3/4   PUR-UKN
                 

Is there a way for me to suppress a group if it contains a value?  What I want is to not see is no groups containing a TranType of 'STK-MTL' so that only the last 3 groups should be shown.


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 07 Jul 2009 at 6:50am

For this situation, if you can't filter it out in the select statement, I would try a subreport.  Have it run in say GH1a. Suppress GH1a, so that you can't see the report.  Have it update a shared variable to true if the TranType you don't want to see is in the subreport, and then use the shared variable to suppress the group.  Depending on the number of records, it could seriously impede the report as it is running the report twice.

 
What else could we try...create a subreport and place it in the report header, have it build a formatted string of group numbers that have the trancode in it.  Then in the group suppression formula, check if the group number is in the formatted string...yes suppress, no display.  Still runs through the data twice, but is probably faster and more effective in the long run.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Jul 2009 at 9:35am
You can also create a formula field to SUM the instances of 'STK=MTL' at the group level then use that SUM to either exclue the groups in the Seelct Expert Group consitions or to suppress the items.
IP IP Logged
ViperSBT
Newbie
Newbie
Avatar

Joined: 02 Jul 2009
Location: United States
Online Status: Offline
Posts: 12
Quote ViperSBT Replybullet Posted: 09 Jul 2009 at 5:23am
Lockwelle and DBlank, both of these appear to be viable options, but just beyond my grasp.  Can you point me to more detailed instructions or a sample of what you are talking about?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Jul 2009 at 6:19am
unfortunately, not many examples exist, they seem to exist in the minds of people who write reports, there aren't many good books on the subject either, but I like Brian's.  With that said...
 
I am assuming that you know how to create a subreport.  This subreport is not for display, it is just to find the part numbers that have the trancode you want to hide, so there isn't much to it.  In fact, all that there is a formula in the details section.  The formula would look something like:
 
shared stringvar badParts;
if {table.trantype}="STK-MTL" then
 badParts := badParts + "|" + {table.partnu} + "|"
 
place the subreport in the report header and go to its properties and select suppress on the general tab.  From previous posts, make sure that the subreport is a section by itself ( i never use the report header, so it would be by itself, also, the report header is only 'read' once per report)
 
Now go to Section Expert, select the group that is partNu, click the 'x-1' box next to suppress and enter something like:
shared stringvar badParts;
instr(badParts, "|"+{table.partnu}+"|")>0
 
 
that should do it.  shared variables cross the subreport boundary (globals don't). In a suppression formula, returning a 'true' means to suppress.
 
Just be careful, since suppressing a value doesn't 'remove' if from the aggregates like SUM or COUNT, which will make your report look incorrect, but if you aren't using any aggregate fields in the report, then all should be fine.
 
Hope this helps a bit more.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jul 2009 at 6:42am

For the process I suggested:

Create a formula field called "ExcludeCount" (or whatever) as :
if {table.trantype}="STK=MTL" then 1 else 0
Using this new formula field Create a Summary (click on the Sigma button) as a SUM at group level 1.
Now any group where the SUM is >0 have STK everything else does not.
Go into the Select Expert.
Click on Show Formula
Change the toggle to Group Selection
Add the selection criteria of: SUM({@ExcludeCount},groupfield)=0
 
NOTE: Excluded data will still appear in the group Tree but not the report.
 
Or
 
If you just want to suppress (rather than exclude) you can use the same Summary field to conditionally suppress each field or section of your choice:
 
 


Edited by DBlank - 09 Jul 2009 at 6:45am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Jul 2009 at 7:22am
Don't know why, I never thought of summing based on a formula for a criteria...I was wondering, about how you meant to do that, but...
 
It just didn't occur to me to sum on a formula...which might make some of my reports less complex as I can just sum on the formula...
 
Thanks DBlank, always a joy to learn something new that can help me out in my report writing.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum