+ Reply to Thread
Results 1 to 5 of 5

Sum Large with Conditions

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2009
    Location
    vancouver, bc
    MS-Off Ver
    Excel 2007
    Posts
    9

    Sum Large with Conditions

    Hi!
    I have a question that to put into simple terms as a smaller example is:
    1. Column A1:A10 has 10 numbers in it
    2. Column B1:B10 has 10 numbers in it
    3. Cell C1 requires a formula to find the sum of the largest 4 numbers in column B under the condition that the sum of the horizontally adjacent numbers in column A for each of those 4 largest numbers is less than say 18.

    So, if column A had 1,2,3,4,5,6,7,8,9,10 and column B had 10,20,30,40,50,60,70,80,90,100 then the function would take the sum of (30+40+50+60 = 180) because they are the largest 4 numbers that 3+4+5+6 which = 18 are adjacent to. Of course their could exist cases where there is more than one answer (even in this problem?) so either I just need one or if possible all of them. Would be nice to know which actual cells or at least their values that are being used. I've tried using =SUM(LARGE(B1:B10,{1,2,3,4}) and putting in various < conditions but can't get it right. Thanks for the help.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum Large with Conditions

    Welcome to the forum.

    That seems like a very non-trivial problem.

    Seems to me you need to calculate all the partitions of 18, i.e.,

    18, 17+1, 16+2, 16+1+1, 15+3, 15+2+1, 15+1+1+1, 14+4, 14+3+1, 14+2+2, 14+2+1+1, 14+1+1+1+1, 13+5, 13+4+1, 13+3+2, 13+3+1+1, 13+2+2+1, 13+2+1+1+1, 13+1+1+1+1+1, 12+6, 12+5+1, 12+4+2, 12+4+1+1, 12+3+3, 12+3+2+1, 12+3+1+1+1, 12+2+2+2, 12+2+2+1+1, 12+2+1+1+1+1, 12+1+1+1+1+1+1, 11+7, 11+6+1, 11+5+2, 11+5+1+1, 11+4+3, 11+4+2+1, 11+4+1+1+1, 11+3+3+1, 11+3+2+2, 11+3+2+1+1, 11+3+1+1+1+1, 11+2+2+2+1, 11+2+2+1+1+1, 11+2+1+1+1+1+1, 11+1+1+1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 2+2+2+2+1+1+1+1+1+1+1+1+1+1, 2+2+2+1+1+1+1+1+1+1+1+1+1+1+1, 2+2+1+1+1+1+1+1+1+1+1+1+1+1+1+1, 2+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1, 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1


    ... then find all subsets of those partitions that appear in col A, then sum the adjacent values in col B, and find the max among those.

    Maybe I'm missing an insight ...
    Last edited by shg; 09-29-2009 at 08:06 PM. Reason: partitions wrong
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-29-2009
    Location
    vancouver, bc
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Sum Large with Conditions

    Thanks for the response but not what I require. The sole aim is to find the 4 largest numbers in a column (will be a lot more data than shown below) that falls under the condition: the cell next to whatever those 4 largest is added to together must equal a certain number to be specified. So the actual 4 largest numbers in a whole column of data might be in say cell A1, A2, A3, A4 and in B1, B2, B3, B4 (the cells right next to them) each have a value too. And those added together will equal something. But that something has to be the certain number to be specified OR ELSE the largest numbers which were found in A1,A2,A3,A4 do not matter. It must find the 4 largest numbers in column A whose adjacent cell values sum to a specified total.

    The application is trying to find the largest 4 points per game cells in a list of hockey players who have all been assigned a dollar value from 1 to 10, and say for example you cannot "spend" more than 30 dollars to buy those 4 players. So I want to find the largest 4 points per game cells that spend as close to 30 dollars as possible to show who the best players are. Make sense?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum Large with Conditions

    Then why not sort by col B descending, and choose sequentially until you reach the cap in col A?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum Large with Conditions

    Actually, create a new column that is the ratio of col B to col A (bang for buck), sort that descending, and choose from the top.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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