Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Random records Post Reply Post New Topic
Author Message
lyman
Newbie
Newbie
Avatar

Joined: 01 May 2009
Online Status: Offline
Posts: 12
Quote lyman Replybullet Topic: Random records
     Posted: 19 Jul 2012 at 8:19am
I'm working on a report which needs to pull 10 percent of individuals receiving a particular medication and sorted by program and prescriber.
 
I started with a Record Selection that limits the records to a date range and the med.  There are 3 groups on the report; Program, prescriber, and patient.
 
I need to end up with lists of the patients' charts that will be audited.
 
This is what I tried:
 
A formula field, @RandomNumber contains only {Rnd()} and was placed in the detail section but that gives a random # for each script written.  I moved the field to grpheader3 where it gives a random # for each patient and surpressed the detail line.
 
A running total {#grpcount} that does a distinctcount of the patient ID field, evaluate for every record, reset never - was added to groupfooter2
 
Group/Sort Expert for group3 is sorted on {all} and based on summary field Max of @RandomNumber which is placed in grpfooter3
 
I think I'm on the right track but need some help on the surpression part.
 
In groupheader 3 and groupfooter3 I tried to surpress with
{#grpcount}>(.1*count({med_name})))
but it surpresses all the records. If {med_name} in the surpression formula is traded for {patient}, then none of the records are surpressed.  I'm missing something.
 
 
 
 
 
 
 
 
 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jul 2012 at 9:15am
not following your logic exactly.
just adding a random number does not do anything as far as making be part of your 10% or 90%.
One way I addressed this was:
add a random number formula to the detail section,
sort by that random number
suppress the details based on either a record count or a percentage of the total records in the report
 
 
 


Edited by DBlank - 19 Jul 2012 at 9:17am
IP IP Logged
lyman
Newbie
Newbie
Avatar

Joined: 01 May 2009
Online Status: Offline
Posts: 12
Quote lyman Replybullet Posted: 20 Jul 2012 at 10:32am
I wrote really badly.  The report is working fine...up to a point
To re-cap the issue
The record selection is a date range and the individuals receiving a certain med. The report has header 1 as the program, header 2 as the prescriber and header 3 as the individuals.  The detail line is supressed and contains a rnd() field, and the field is sorted so it is working correctly and the 'random-ness' is there.  Footer 2 has a running total, doing a distinct count on the individuals for each prescriber.  Also in footer 2 is a number which is 10 percent of the running total but rounded up so each prescriber will have at least one chart audited even if they have less than 10 clients.  So far, so good - everything works.
 
The problem:
They only want to see the individual's charts that will be audited.  So, prescriber 1 has 23 clients but only 3 will be choosen for audit so only those 3 names should appear in header 2. 
 
I've tried a number of things but either none of the names supress or all the names supress.  I don't do a lot in crystal and I'm hoping that there is a method to pick up the numbers in the footer and go back to the header.
 
Hope that this makes more sense.
 
 
 
 
 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Jul 2012 at 4:39am
you would have to do this in the footer as you are essentially doing calculations after the header has been built. the only other solution I can think of would be to use subreports in the header (if the data must be in the header).
I am still confused as to how you are getting random selections though. Perhaps I am just not 'seeing' your design accurately... 
by grouping you are sorting (alpha)
You are adding a random number to detial lines but that is not in direct relation to your 10%, it is just a random number.
if you dio not group by client then you can sort by the random number and just conditionally suppress rows based on the 10% and show a random list of clients


Edited by DBlank - 26 Jul 2012 at 4:41am
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