I've not looked at tresecco's idea but this is how I would do it
- Start by adding random numbers to the accounts
Accounts: Load rowno() as AccNo, rand() as RandNo AutoGenerate(12345);
- Add a "Random" integer from 1 to the total number of rows by sorting by the random number, and adding the rownumber:
Load AccNo, Rowno() as Rank resident Accounts order by RandNo;
- Work out how many Accounts each agent needs, put this in a variable:
let vNumAgents = 20;
let vNumAccounts = NoOfRows('Accounts');
let vFactor= $(vNumAccounts)/$(vNumAgents);
- Divide the random "Rank" integer in the accounts table by this figure and round up to get the number for the Agent.
Load AccNo, ceil(Rank/$(vFactor),1) as AgentNo resident Accounts_Sorted;
You will now have 20 agents allocated randomly to 12345 accounts, this can change each day!
Is this what you need?