Results 1 to 4 of 4
  1. #1
    JerBearMO is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    2

    Distributing Records Equally by Value

    I have a table in which each record represents an account. Within each record is a number of contracts that is associated with this account, along with the total dollar value of these contracts.

    What I need to do is to assign a bucket to each of these records so that the number of accounts and the total dollars in each bucket is as equal as possible. The number of buckets will be supplied by the user. (It will likely range from 1 (yay, easy!) to 10 or so.)

    I'm not looking for all of the code involved, just a general pointer so that I can do this with as little error rate as possible.

    Any suggestions would be most welcome!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Not understanding. As equal as possible to what?

    Record, account, bucket are all synonyms for the same item? Each record/account/bucket has contracts. How can a number of contracts be within a single record?

    Show examples of source data and desired output.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JerBearMO is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    2
    Sorry for the confusion. Let me explain more clearly. :-)

    The accounts table contains the fields AccountNumber, NumberOfContracts, DollarValue, and a blank field, GroupNumber.

    Example data:
    AccountNumber, NumberOfContracts, DollarValue, GroupNumber
    10000, 2, $500,
    10001, 4, $725,
    10002, 2, $225,
    10003, 1, $700,
    10004, 3, $25,

    The user will input an integer indicating the number of GroupNumber to be used. For this example, let's say three. I then want to assign each of these records a group number between 1 and 3. When all GroupNumber have been assigned, I want the sum of NumberOfContracts and the sum of DollarValue to be as close as possible between each of the three groups. Example:

    10000, 2, $500, 1
    10001, 4, $725, 2
    10002, 2, $225, 1
    10003, 1, $700, 3
    10004, 3, $25, 3

    In this example, each group number contains records where the sum of the NumberOfContracts is now 4 and the sum of the DollarValue is now $725. Of course, I'm doing this with a much larger table.

    Does this help?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Pseudocode:

    1. sum DollarValue, divide by input to get the target dollar value for each group

    2. sum sequential records and assign group number until target met

    3. continue summing records with next group number

    4. repeat 3 as often as needed to reach given number of groups target

    This will require VBA code. Not a task I wish to tackle.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. distributing Access front ends
    By gunner in forum Access
    Replies: 10
    Last Post: 03-15-2011, 03:53 PM
  2. Distributing an Access App to the Masses
    By AccessGeek in forum Access
    Replies: 3
    Last Post: 03-03-2011, 08:58 AM
  3. Distributing Reports
    By zp18zp18 in forum Reports
    Replies: 3
    Last Post: 01-09-2011, 01:16 PM
  4. Distributing Access 2007 Application
    By AndreQ1 in forum Access
    Replies: 2
    Last Post: 09-08-2010, 09:27 AM
  5. Evenly distributing fields
    By pledbetter in forum Forms
    Replies: 7
    Last Post: 01-08-2010, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums