Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
select random sample of records in a filtered list | Excel Discussion (Misc queries) | |||
Selecting Random Records From an Excel Sreadsheet | Excel Worksheet Functions | |||
select multiple records in database given conditions | Excel Worksheet Functions | |||
draw 999 x 8 random records from file with 8614 records | Excel Programming | |||
selecting random records | Excel Programming |