+ Reply to Thread
Results 1 to 5 of 5

All possible combinations from dynamic list

Hybrid View

  1. #1
    Registered User
    Join Date
    11-29-2010
    Location
    Nashville
    MS-Off Ver
    2010
    Posts
    76

    All possible combinations from dynamic list

    Hi,

    I'm trying to generate alternate criteria sets from a given criteria set, in this case, for real estate.

    I have formulas that vary input criteria and generate unique lists. For example, for Price, I do increments of $50k up to 2x input, for Bedrooms, I vary 2 up and 1 down.

    So if I input $100,000 - $200,000 with 3 Bedrooms, I get the following lists:

    $150,000 - $250,000
    $200,000 - $300,000
    $250,000 - $350,000
    $300,000 - $400,000

    and

    2 Bedrooms
    4 Bedrooms
    5 Bedrooms

    So the alternate criteria sets for the input criteria set are:

    2 Bedrooms, $150,000 - $250,000
    2 Bedrooms, $200,000 - $300,000
    2 Bedrooms, $250,000 - $350,000
    2 Bedrooms, $300,000 - $400,000
    4 Bedrooms, $150,000 - $250,000
    4 Bedrooms, $200,000 - $300,000
    4 Bedrooms, $250,000 - $350,000
    4 Bedrooms, $300,000 - $400,000
    5 Bedrooms, $150,000 - $250,000
    5 Bedrooms, $200,000 - $300,000
    5 Bedrooms, $250,000 - $350,000
    5 Bedrooms, $300,000 - $400,000

    In the real case, I have not two lists to combine but six: Price, Bedrooms, Bathrooms, Half-Baths, Square Footage, and Acreage, resulting in possible combinations in the 20-30,000 range, each with changing lists based on inputs. I considered implementing this formulaically, and would still prefer that, but my attempts were too calculation-heavy and brought my system to a halt.

    My gut says that this has been done many, many times before, so I am trying to avoid reinventing the wheel. Anyone able to help?

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Cool Re: All possible combinations from dynamic list

    You're trying to create a Cartesian product - all combinations of values in multiple unrelated fields.

    There are several ways to do this, but one of the fastest (and simplest, once set up) is by using MS Query, with your Excel Workbook as the data source.

    First, create a named range for each of your six lists of values. Make sure the field name (header) is included in the named range.

    Now, create a data connection, from Other Sources > MS Query > Excel Files, and choose your workbook. Your named ranges will appear as tables, with the header values as field names.

    Select the header field from each of your 6 tables, and click next. You may get a warning message about the wizard being unable to deal with there being no join between the tables - you can ignore that, click OK. Then simply click the 'Return Data' button, and choose where to place your table, which now contains all possible combinations of values for your 6 lists

    Now, as long as you keep your named ranges up to date to reflect your lists of values accurately (dynamic named ranges may help here), then you can simply refresh the data table to update the list of combinations. Neat eh?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    11-29-2010
    Location
    Nashville
    MS-Off Ver
    2010
    Posts
    76

    Re: All possible combinations from dynamic list

    @OllyXLS

    Sorry for the delayed response, I don't seem to be getting notifications.

    I was aware of the Query function, but I didn't know that I could just refresh on it! That's great!

    I'm still having a challenge though. My dynamic fields vary in number of rows. I found that the Cartesian Sets are made from the number of rows in the named range. So if I have, say, 20 rows in each Named Range for 3 Named Ranges, my total number of possible combinations would be 8000, and the query will produce 8000 combinations, even if there's only data in 3 rows.

    How do I get around this, so I only have the query looking at cells with values in them?

    I'll send this via PM as well.

  4. #4
    Registered User
    Join Date
    11-29-2010
    Location
    Nashville
    MS-Off Ver
    2010
    Posts
    76

    Re: All possible combinations from dynamic list

    Just discovered how to change the parameters in a Microsoft Query to look at only "Not Null". However, I have found this doesn't work with cells that have a formula but are blank. So I'm experimenting with using pivot tables as sources. We'll see how that goes.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: All possible combinations from dynamic list

    Set field criteria '<>""'

+ 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. Need a list of combinations
    By Iduno in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2013, 11:11 AM
  2. list possible combinations of 6 from 22
    By nlscarter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-19-2013, 10:13 PM
  3. List Possible Combinations
    By Rizzle in forum Excel General
    Replies: 10
    Last Post: 09-29-2010, 09:36 AM
  4. Dynamic variable state combinations
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2007, 05:48 AM
  5. List all possible combinations
    By Spencer Hutton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2005, 04:06 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