Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Filtering groups by condition Post Reply Post New Topic
Author Message
jvenuto80
Newbie
Newbie


Joined: 14 Oct 2009
Location: United States
Online Status: Offline
Posts: 2
Quote jvenuto80 Replybullet Topic: Filtering groups by condition
     Posted: 14 Oct 2009 at 9:51am
I am currently using Crystal 11.

I have written a report that is grouped by user and lists all desktops and laptops that are associated with that user, which could be 2 or more desktops or a desktop and a laptop.  What I would like to do is show only users that have a desktop and a laptop associated with them and not users that have 2 or more desktops.

example

  Machine Name      Primary User      Computer Model
User 1
   Computer1            User 1                Desktop
   Computer2            User 1                Desktop

User 2
   Computer3            User 2                Desktop
   Computer4            User 2                Laptop

Any help would be much appreciated.    


Edited by jvenuto80 - 14 Oct 2009 at 12:25pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Oct 2009 at 6:52am
write a subreport to count the number of desktops, return the number via a shared variable, suppress the user and detail if the variable returns a number >1.
 
HTH
IP IP Logged
jvenuto80
Newbie
Newbie


Joined: 14 Oct 2009
Location: United States
Online Status: Offline
Posts: 2
Quote jvenuto80 Replybullet Posted: 15 Oct 2009 at 8:55am
Thanks for the reply.
I dont want to exclude users that have 2 or more desktops and a laptop so  I wrote the subreport that lists all users with laptops using a sql clause to narrow it down.  How would I pass the users to the main report from the subreport and suppress the users on the main report that are not listed on the subreport.

Thanks for any help
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Oct 2009 at 12:14pm
Assuming you want to do this in Crystal and not outside of Crystal then another approach would be to make a formula field to count your Laptops per user and then use a group select statment to exclude groups where the SUm(formula,group)=0.
@LaptopCount would be something like:
if {table.computermodel_field}='Laptop' then 1 else 0
In the select expert clcik on show formula, change the toggle to 'Group Selection', click on the formula editor and add your condition here:
 
Not that this will still leave the excluded user groupings in the Group Tree but remove them from the report canvas.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Oct 2009 at 6:09am
DBlank's method is probably more elegant, but there are a couple solutions that come to mind.  Count the number of laptops, instead of desktops and suppress where the count = 0 (Basically DBlank's solution...or mine, just changing the logic).  Or put the 'good' users into a delimited string or an array and pass them back to the main report via shared variables and suppress the groups based on if the user in the string/array.
 
HTH
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