Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Sample with Groups 1

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
0
0
CA
Hello

I've looked at other posts about this but can't seem to get it to work so looking for assistance.

I have a report where I would like 275 charts selected at random but covering all 9 months of data. So I'm grouping on Month and the detail section is chart and account number.

I created the field of random number which is just Rnd() which is what the report is sorted on and I use the record number of 275 to suppress at the detail level i.e. recordnumber>275. Doing this means that I only get data for Apr to Jun for all 275 charts and I want them to be from all months - how do I do that?

All assistance greatly appreciated.
 
It's not totally random if you are requiring that each month be represented, so you probably need to decide to select a random sample within the month group, e.g., 30 or 31 from each of nine months. So you can still add the rnd() formula as your sort field, and that will sort within the month group. Then create a running total that does a count of nay recurring field, evaluate for each record, reset on change of group (month). Then use a suppression formula like this;

{#rt} > 31

You could add a condition to the suppression formula where every other month has an extra chart, e.g.,

if remainder(month({table.date}),2) = 0 then
{#rt} > 31 else
{#rt} > 30

Not sure whether your 9-month range is always the same or not, to know whether this would give you the exact 275.

-LB
 
Hi LB

Thanks this worked!

I realize it's not totally random if ensuring representation from each month but without doing that you'd only get charts from the first two months.

Thanks again.
 
Hi

To expand on this idea, how would I do this if I had two groups t work from? So I group on Hospital and the second group is Month?

Thanks.
 
What would you be expecting for results in this case? Random sample within each month within each hospital? If so, the principal would remain the same--you would just change the number depending upon the number of hospitals.

-LB
 
Hi LB

Yes that is what I want to do...but do I just add the group and then add another running total? And then supression is based on both running totals?

Thanks.
 
Since the hospital is the outer group, the current running total (reset on change of month) will still work. You don't need another running total. If you have 6 hospitals, for example, you would change the number criterion to about 5 per month: 275/9 months/6 hospitals.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top