+ Reply to Thread
Results 1 to 18 of 18

Formula to give all the possible combinations

  1. #1
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Formula to give all the possible combinations

    Hello. I need a formula(s) to write all the possible combinations between multiple variables.

    Lets say we have a sheet with the follow itens:

    Column A - A/B/C/D
    Column B - E/F
    Column C - G/H/I
    Column D - J/K/L/M/N

    How many combinations with 2 variables (ex. A-G / C-M / etc.) there are? And with 3 (ex. A-G-N / C-E-I / etc.)? And with all together (ex. A-E-G-L / C-E-H-J / etc.)?

    Is it possible to write a formula to give us all the combinations?

    Thank you in advance for any help.

    Best regards,
    Eduardo Cruz
    Last edited by edneco; 10-20-2022 at 10:32 AM.

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Combinations - Need formula

    are you still on XL 2007? if not - update your profile
    anyway read big yellow banner at the top of this site

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: Combinations - Need formula

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Re: Formula to give all the possible combinations

    Hello again,

    Here is the spreadsheet. I hope you can understand what I want to do.
    Attached Files Attached Files
    Last edited by edneco; 10-20-2022 at 04:36 AM.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: Formula to give all the possible combinations

    Where have you manually mocked up your expected results? I can see only a cell with the word 'comment' in it - this isn't very helpful.

  6. #6
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Re: Formula to give all the possible combinations

    Hello AliGW,

    I don't know what "manually mocked" means, but this spreadheet I made my self and put the few combitanions that is on it by hand.

    Again, what I need is the formula to give the all possible combinations.

    A formula for 2 variables (Column A with Column B, Column A with Column C and Column B with Column C) and a formula for the 3 variables.

    I re-attach the file without the comments.


    Thank you for your attention.


    Data-Eduardo_v1.xlsx

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: Formula to give all the possible combinations

    No, sorry - still not clear to me. I'll leave this to someone else who may understand what you mean.

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to give all the possible combinations

    with duplicates

    Data 2 Data 1 Count Sum
    E B
    20
    101238.84
    E A
    17
    100415.56
    E C
    28
    16357.36
    F B
    20
    106794.63
    F A
    17
    105926.17
    F C
    28
    17255.02
    D B
    20
    120992.76
    D A
    17
    120008.84
    D C
    28
    19549.04


    without duplicates

    Data 2 Data 1 Count Sum
    E B
    20
    -920.69
    E A
    17
    -799.71
    E C
    28
    -1308.26
    F B
    20
    -920.69
    F A
    17
    -799.71
    F C
    28
    -1308.26
    D B
    20
    -920.69
    D A
    17
    -799.71
    D C
    28
    -1308.26


    which one?

  9. #9
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Re: Formula to give all the possible combinations

    Thank you Sandy666.

    But I don't understand what you mean with or without duplicates. From what I see the count of each combination are the same but I don't see how you came with that sum values.

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to give all the possible combinations

    because above are counted distinct rows but here - all rows (with duplicates)

    Data 1 Data 2 Count Sum
    B E
    30668
    109308.98
    B F
    32351
    29710.56
    B D
    36652
    109567.04
    A E
    28044
    99956.34
    A F
    29583
    27168.48
    A D
    33516
    100192.32
    C E
    28700
    102294.5
    C F
    30275
    27804
    C D
    34300
    102536

  11. #11
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Formula to give all the possible combinations

    Could you explain your question in more detail?

    In post #1 your question is about counting and finding all combinations given the letters allowed in each column.
    Your example sheet is about determining a sum per given combination.

    That is quite another.

  12. #12
    Registered User
    Join Date
    10-20-2022
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    2

    Re: Formula to give all the possible combinations

    Hi Edneco,

    Not sure what you are trying to achieve here. I am attaching the your previous XLS file, wondering if that solve your problem.

    Cheers,
    Novan
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Re: Formula to give all the possible combinations

    Quote Originally Posted by HansDouwe View Post
    Could you explain your question in more detail?

    In post #1 your question is about counting and finding all combinations given the letters allowed in each column.
    Your example sheet is about determining a sum per given combination.

    That is quite another.

    The main question is to find all the possible combinations in the first place. 3 columns with 3 different variables in all collumns.

    I think there are 27 possible combinations:

    ADG ADH ADI AEG AEH AEI AFG AFH AFI BDG BDH BDI BEG BEH BEI BFG BFH BFI CDG CDH CDI CEG CEH CEI CFG CFH CFI

    This is simple because there are a few variables. But what if I have 5/6 different variables in 10 columns?

    That´s why I´m trying to find a formula to give all these combinations. See my point.

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Formula to give all the possible combinations

    I think there are 27 possible combinations
    You are right, it is 3 times 3 times 3 = 27

    If you put the numbers of different variables in column A the formula that calculates the number of possible combinations is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Now that you can easily calculate the possible number of combinations, do you also want a formula that creates all those combinations?

  15. #15
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to give all the possible combinations

    try this one
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    07-10-2021
    Location
    GENEVA
    MS-Off Ver
    EXCEL FOR MAC MICROSOFT 365
    Posts
    83

    Re: Formula to give all the possible combinations

    Hi Edneco,
    I can see exactly what you want to achieve.

    To find all possible unique combinations you need to use the "=Unique" function, like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    for the two columns, and like this for the 3 columns:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    . Put those formulas in your cells f2 and j2

    Now you have to lists of all possible combinations in a list going down, with only 1 of each possible set of letters, e.g. "BEH".

    You can easily adapt your COUNT and SUM formulas by using the "mid" function to extract the first, second or third letter.

    So in your cell L3, you would replace the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    with the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Copy and paste your formula downwards.



    I attach your spreadsheet in which I have solved what you want to achieve.

    Please thank and mark "solved" if this is the solution you are seeking.
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Formula to give all the possible combinations

    Why not use PivotTable?
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    11-11-2013
    Location
    Portgal
    MS-Off Ver
    Excel 365
    Posts
    64

    Re: Formula to give all the possible combinations

    TRICKYT57, fantastic....

    That is exactly what I want.... I´m just gonna to try if this results if I have different numbers of variables in each column (Column A - 3 variables, Column B - 2 variables, Column C - 5 variables)....


    Again, thank you very much for help....

+ 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. Replies: 0
    Last Post: 03-20-2021, 01:13 AM
  2. Replies: 2
    Last Post: 09-04-2017, 07:13 PM
  3. [SOLVED] Need formula for different combinations
    By Excelski in forum Excel General
    Replies: 7
    Last Post: 06-28-2017, 01:25 PM
  4. Formula for Combinations and Corresponding Sums
    By Tyler72098 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-13-2015, 06:36 PM
  5. Combinations using Formula
    By newbie1234 in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 04-03-2013, 02:11 AM
  6. Finding possible combinations & listing the wanted combinations
    By Zoke in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 07-16-2012, 03:41 PM
  7. Combinations and Permutations Formula
    By boydam in forum Excel General
    Replies: 7
    Last Post: 02-03-2010, 12:31 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