Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: HELP - Show only one group data Post Reply Post New Topic
Author Message
albertleung
Newbie
Newbie


Joined: 20 Sep 2011
Online Status: Offline
Posts: 2
Quote albertleung Replybullet Topic: HELP - Show only one group data
    Posted: 20 Sep 2011 at 4:00pm
Hi there, I have a data as following:
Name    Category
Sam     Group1
Sam     Group2
Susan   Group1
Dixie   Group1
Julio   Group1
Julio   Group2
Albert Group2

Some people have more than one categories. And user can choose what category to show on the report, such as Group1 only, Group2 only, or both. However, Group1 has priority, which is we don't want Group1 people show up as Group2. For instance, if user selects Group2 people only, I don't want people have both Group1 & Group2 show on the Group2 only report, but they should show on the Group1 report or show Group1 category if user selects show both.

What can I do in Crystal Report?

Thank you.
Albert
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 20 Sep 2011 at 10:07pm
This is a pretty tricky problem. I'll try to explain what I would do, but it will be tough without actually having a similar report in front of me.

First, I would create a report that groups by Name. In the Group Footer, create a subtotal for the number of records printed for that person. Thus, this will tell you if that person is just the member of one group, or more than one group.

Second, hide the Details section b/c you don't want the individual records printed on the main report.

Third, create a subreport in the group footer which is passed the subtotal field and the category to be printed. Using logic in the Suppress property's formula workshop, you will need an involved formula which checks to see what the user selected (Group1, Group2, or Both Groups) and the subtotal value. Something like this (you will have to work on this to get it actually working in your report):

Shared NumberVar NameSubtotal;
Shared StringVar TypeOfReport;
if TypeOfReport = "Group1" and NumberVar=1 and {table.field}="Group1" Then False; //don't suppress

Do this for the other possible combinations of report types. It will take some time to get all the combinations figured out, but I think this is a way for you to get your report working.

Brian
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2011 at 4:45am
a thought...I think you can avoid using a sub report.
If you group on Name and write 2 formuals to count/flag instances of each category
//CAt1
if category='Group1' then 1
//Cat2
if category='group2' then 1
and sum both formulas in the group footer you now can tell who has group 1 only...
SUM(@cat1,name)>0 and SUM(@cat2,name)=0
who has group 2 only...
SUM(@cat1,name)=0 and SUM(@cat2,name)>0
who has group 1 and group 2...
SUM(@cat1,name)>0 and SUM(@cat2,name)>0
 
you can use these in your group select criteria alog with your paramter(s)
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.