Results 1 to 8 of 8

Creating Combinations Based on Certain Criteria?

Threaded View

  1. #7
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Creating Combinations Based on Certain Criteria?

    Hi Jack,

    I've gone down the approach of generating all possible combinations of 3 items from the list you have there using formulas (as you can see attached file, sheet OUTPUT)

    Columns A:C generates all possible combinations of 3 items from a list of 18.
    Formula: copy to clipboard
    A1 = 1, B1 = 2, C1 = 3
    A2: =IF(B2=18-1,A2+1,A2)
    B2: =IF(C2=18,IF(AND(C2=18,B2=18-1),A3+1,B2+1),B2)
    C2: =IF(C2=18,B3+1,C2+1)
    Note: This can be extended by finding all "18s" in the formula and replacing them with a different number. Then use the formula =COMBIN(NewNumber , 3) to figure out how many more rows you need to add to the bottom of the list.

    Columns E:G converts them into alphabets, as per your table using a simple INDEX. Same with columns I:K (prices) and N:P (ratings)
    Formula: copy to clipboard
    E2: =INDEX('Sample Data (Before)'!$A$2:$A$19,A2)
    I2: =INDEX('Sample Data (Before)'!$C$2:$C$19,A2)
    N2: =INDEX('Sample Data (Before)'!$B$2:$B$19,A2)


    I then calculate find the largest rating that are below 18,000 using a MAX IF on column L (sum of prices) and column Q (sum of ratings)
    Formula: copy to clipboard
    =MAX(IF($L$2:$L$817<=T$2,$Q$2:$Q$817))

    Note: This is an array function, and as such, as you type the formula, hit CTRL SHIFT ENTER to finalise the formula rather than just enter.

    To address the possibility of multiple solutions, I've also prepared a table to give you 5 possible solutions using
    Formula: copy to clipboard
    U7 (row number of solution) =IF(T7<=$T$5,LARGE(INDEX(($L$2:$L$817<=$T$2)*($Q$2:$Q$817=$T$4)*ROW($Q$2:$Q$817),0),T7),0)
    where T5 is a COUNTIFS of how many solutions there are
    T5: =COUNTIFS($L$2:$L$817,"<=" & $T$2,$Q$2:$Q$817,$T$4)
    and finally extracting out the solution
    V7: =IF($U7=0,0,INDEX(E$2:E$817,$U7-1))
    W7: =IF($U7=0,0,INDEX(F$2:F$817,$U7-1))
    X7: =IF($U7=0,0,INDEX(G$2:G$817,$U7-1))


    Or you can just see attached.

    P/S: Clearly, I have too much free time to kill today.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create list of combinations based on changing criteria
    By NamiSama in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-15-2014, 01:41 PM
  2. [SOLVED] Creating combinations with criteria
    By sans in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2012, 02:44 AM
  3. Creating list based on 3 criteria
    By bd528 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2010, 01:45 PM
  4. Creating Line Graph Based On Criteria
    By SeanKosmann in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-26-2010, 05:44 PM
  5. Creating a Sum of Data based on Job # Being Criteria.
    By DPaul in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-21-2009, 08:43 PM
  6. Creating combinations based on a criteria
    By Maxi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2006, 10:00 AM
  7. [VBA] Creating sheets based on criteria
    By Sune Fibaek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2005, 06:05 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