+ Reply to Thread
Results 1 to 11 of 11

SUM totals for specific groups

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    SUM totals for specific groups

    Hello everyone

    I have those numbers
    --------------------------
    142
    158
    94
    55
    15
    37
    22
    60
    33
    70
    58
    28
    52
    25

    I need to divide those numbers into five groups .. and as possible as it can be to have nearest equals for each group
    The total of these numbers are 849 >> so each group would be nearly about 170 ..
    * Each number will be used just for once ..

    How can I form the five groups of these numbers to be as possible as it can be to be equal somewhat ??

    Posted here too
    http://www.eileenslounge.com/viewtopic.php?f=30&t=33777
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: SUM totals for specific groups

    Create yourself a solver macro

    https://www.ppchero.com/how-to-automate-excel-solver/

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    Thanks a lot. I have a look but I can't do it ..
    I will try again when my mind is a little fresh

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: SUM totals for specific groups

    Perhaps a setup using a binary grid? Tested both excel solver and freebie OpenSolver result a bit different as excel solver needs a bigger gap between min an max
    group value but average for both solutions is the same.

    Alf
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    That's great Alf. Thank you very much
    Can you explain the steps by details that lead to such great result??

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    I have studied the file well and I could get how the steps go through
    Thanks a lot for great help

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    I tried to do the same with four groups instead of five groups but I got unreasonable and incorrect results ...
    Can you attach another attempt with the four groups so as to review the results with mine?

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: SUM totals for specific groups

    Thanks for feedback and rep

    You said the average for each group should be around 170 and and every number should be used once so for the cells to change I used binaries and the sum should of course be 1 as one can only use a number once.

    As the average was a decimal number a set a min and a max value for the sum of each group and here I just tested different numbers and found the best min and max value for the excel solver was 174 and 166. So even if solver found a solution where max was 173 and min was 167 using those values did not make solver find a solution for a long time. Fact is my patience did run out before solver found a solution. Using 174 and 166 as max and min made solver find a solution in a matter of seconds.

    The setting of the target cell B19 to min and specifying a constraint as well B19 => 0 is an old habit of mine so looking at the present setup it's much better to set target cell B19=0 and remove the constraint B19 => 0.

    Doing so you can also change the groups max and min values to 173 and 167 and this time solver will find a solution in a few seconds the same as the one OpenSolver found i.e.
    171, 167, 167, 171 and 173 so how one sets up the model may have quite an impact on the final result.

    Alf

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    Thank you very much. In fact as for five groups as you explained work well. Now I am trying to do the same but with four groups
    Is there a way to determine the best min and max values ..? No matter if the differences are large but to make the groups as possible as it can be to be nearly equal .. I don't expect exact equals at all

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: SUM totals for specific groups

    Don't know any good way to do that but I would use the average and add a min and max constraint and see if solver will find a solution. If so then I would decrease the gap between min and max util solver can't find a solution.

    There is also the possibility of setting the groups equal to each other by using a number of constraint for instance in my uploaded file on could test by adding C17=D17, D17=E17 and so forth.

    If the average number is an integer then this could work but if the average is a decimal number and the group numbers are integers then it probably won't.

    Depending on the situation you could run a macro that takes the average and based on the average adds a min and a max value and do a loop where the min and max value are changed until solver can't find any solution and this stops the macro.

    Alf
    Last edited by Alf; 12-12-2019 at 03:27 PM.

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: SUM totals for specific groups

    Thanks a lot for great help ..
    Best Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Transpose totals from consecutive groups of cells
    By Tobobo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-16-2018, 06:48 AM
  2. how do I sort this data into groups with totals below each group
    By nightyard in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 01-10-2016, 08:07 AM
  3. count the cell totals of groups
    By mirtjemirtej in forum Excel General
    Replies: 6
    Last Post: 09-10-2009, 09:49 AM
  4. Calculating totals from groups using defined lists
    By reborn64 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-13-2007, 11:41 AM
  5. Pivot Table groups & cumulative totals
    By laureleaw in forum Excel General
    Replies: 0
    Last Post: 04-26-2006, 04:00 PM
  6. [SOLVED] Totals in worksheete groups
    By BJ in forum Excel General
    Replies: 3
    Last Post: 12-13-2005, 06:10 PM
  7. Formula for adding up totals of groups
    By koba in forum Excel General
    Replies: 4
    Last Post: 11-23-2005, 05:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1