Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: CR XI: Select Records where user has applied for m Post Reply Post New Topic
Author Message
bowja
Newbie
Newbie
Avatar

Joined: 07 Dec 2009
Location: Australia
Online Status: Offline
Posts: 31
Quote bowja Replybullet Topic: CR XI: Select Records where user has applied for m
     Posted: 19 Dec 2012 at 7:12pm
Hi,
Apologies if I have listed this incorrectly, it is my first question on the forum.  

The problem:
Generate a report which shows only shifts which are in breach of the users allocation limit for shifts per week.

The data:
id | shift_type | date | user_id

The logic:
Users can only do 3 shift_type "graveyard" per week.

For each user ID i want to check the number of "graveyard" shifts they have done per week and if this exceeds 3 then I want to display the shifts (id, shift_type, date, user_id).

I think I may need a combination of the Select and Loop functions neither of which I have used before.


Cheers,

bowja 
If you think you can or think you can't you are right - Paraphrased quote Henry Ford
IP IP Logged
DaBoujibo
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 28
Quote DaBoujibo Replybullet Posted: 20 Dec 2012 at 6:31am
Are you running this report weekly?  What type of date criteria are you using (or thinking of using)?
IP IP Logged
DaBoujibo
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 28
Quote DaBoujibo Replybullet Posted: 20 Dec 2012 at 9:21am
If you are using a date criteria to only pull the data for a specified week, you can do the following:
 
Selection criteria: start and end date for the week desired
 
(There may be a quicker way of doing the following, but this is what I do for similar tasks.)
 
1. Create a boolean formula to have the graveyard shifts be a 1 and all others a 0.
 
     IF {Table1.Shift_Type} = "Graveyard"
          THEN "1"
          ELSE "0";
 
2. Group based on user id
 
3. Create a count of the boolean formula by group
 
4. Suppress GH, GF, and details with a formula
 
Now you will only see the records you want.
IP IP Logged
bowja
Newbie
Newbie
Avatar

Joined: 07 Dec 2009
Location: Australia
Online Status: Offline
Posts: 31
Quote bowja Replybullet Posted: 29 Dec 2012 at 12:03pm
Thanks DaBoujibo.

I found a similar solution by using groups and a row count and then creating a footer with custom fields on the condition of the group being greater than or equal to 4. I then suppressed all rows except the footer.

It achieved the same result but was more labour intensive to create then your solution.

I think from my research that the grouping solution is the only way to go. As there are not that many breaches this is ok however I think with a large report and data set that checking for selection would be better.
If you think you can or think you can't you are right - Paraphrased quote Henry Ford
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