Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Select random records by two conditions

I need help. I have several hundred records representing transactions
within a particular month. I want to select two random samples for
each client for each day of the month. In other words, select random
samples based on two conditions or criteria. One problem I have
encountered is when there are no examples for a client for a
particular day I get an error. I think the pseudo-code or algorithm
might go a little something like this . . . swing it boys.
Create a collection of dates
Create a collection of names
Create an array to hold records
For the first date
For the first name
For records 1 to infinity
Select a random record
Test for duplication
Add to array
Loop
Write array of records to another sheet
Next name
Next date
I already have some chunks of the code but it doesn’t work as a whole
because I think I have the order of execution wrong. Any help would be
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Select random records by two conditions

Slim Slender wrote:

I need help. I have several hundred records representing transactions
within a particular month. I want to select two random samples for
each client for each day of the month. In other words, select random
samples based on two conditions or criteria.


Give some examples of the records' format(s).

One problem I have
encountered is when there are no examples for a client for a
particular day I get an error. I think the pseudo-code or algorithm
might go a little something like this . . . swing it boys.
Create a collection of dates
Create a collection of names
Create an array to hold records
For the first date
For the first name
For records 1 to infinity
Select a random record
Test for duplication
Add to array
Loop
Write array of records to another sheet
Next name
Next date


I would think it would be more like this (untested air code):

for each c in clients
for each d in dates
r_c_d = [set of records where date is d and client is c]
r_1 = int(rnd * r_c_d.count) + 1
remove r_1 from r_c_d
r_2 = int(rnd * r_c_d.count) + 1
next d
next c

I already have some chunks of the code but it doesn’t work as a whole
because I think I have the order of execution wrong. Any help would be
appreciated.


Maybe my air code will poke some ideas in your direction.

--
I shall go tell the indestructible man that someone plans to murder him.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
select random sample of records in a filtered list David3553 Excel Discussion (Misc queries) 2 November 25th 09 11:37 PM
Selecting Random Records From an Excel Sreadsheet Trevor Aiston[_2_] Excel Worksheet Functions 3 June 29th 09 11:20 AM
select multiple records in database given conditions MayFestivalRon Excel Worksheet Functions 1 May 9th 08 09:49 PM
draw 999 x 8 random records from file with 8614 records news.wanadoo.nl Excel Programming 1 March 1st 06 03:04 PM
selecting random records terry freedman Excel Programming 2 April 2nd 04 11:07 AM


All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"