+ Reply to Thread
Results 1 to 6 of 6

unique combinations in excel

  1. #1
    Forum Contributor
    Join Date
    09-30-2015
    Location
    LA my baby
    MS-Off Ver
    2013
    Posts
    727

    unique combinations in excel

    Hello. In excel, I have a list of numbers and a list of status. Is there a way to write a formula that returns all unique combinations of 0 and the types of status, and then non zero and the associated status? For example, 0 Pay, 0 Pay, 1 Pay, 2 Pay, 0 Free, 0 Pay, would return 0 Pay, Non-Zero Pay, 0 Free. thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: unique combinations in excel

    Hi,

    You can do that with a pivot table.

    See attached example.

    Cheers.
    Attached Files Attached Files

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,422

    Re: unique combinations in excel

    Borrowing from southward's upload, if you would like a formula solutions as well ... array-enter this in a helper column C.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    Then this non-array in D:E
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Row\Col
    A
    B
    C
    D
    E
    1
    Number status
    2
    0
    pay
    1
    0
    pay
    3
    0
    pay
    1
    pay
    4
    1
    pay
    3
    2
    pay
    5
    2
    pay
    4
    0
    free
    6
    0
    free
    5
    7
    0
    pay
    Dave

  4. #4
    Forum Contributor
    Join Date
    09-30-2015
    Location
    LA my baby
    MS-Off Ver
    2013
    Posts
    727

    Re: unique combinations in excel

    Got it. Thanks!!
    Last edited by stephme55; 05-18-2016 at 12:38 PM.

  5. #5
    Forum Contributor
    Join Date
    09-30-2015
    Location
    LA my baby
    MS-Off Ver
    2013
    Posts
    727

    Re: unique combinations in excel

    @flameretired. Could you walk me through what the formula is doing? And is there something easier than that? haha. Thanks.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,422

    Re: unique combinations in excel

    Sure. The helper formula identifies the row number of the first occurrence of unique pairs "Number/status".

    (A2=$A$2:$A$7) generates an array of TRUE/FALSE as does (B2=$B$2:$B$7). When multiplied they coerce the underlying numeric values of TRUE and FALSE .... 1 and 0. Select ((A2=$A$2:$A$7)*(B2=$B$2:$B$7)) in the formula bar and press the F9 function key on the upper keyboard.

    You will see an array that looks like this. {1;1;0;0;0;1}. Reciprocating it looks like this. {1;1;#DIV/0!;#DIV/0!;#DIV/0!;1}.

    MATCH ignores those errors and returns the row number of the 1st 1 (MATCH(1,{1;1;#DIV/0!;#DIV/0!;#DIV/0!;1},0)) it finds which in this case is 1.

    If that match return equals the current row # of the range it returns that row #, else an "" empty string.

    =IF(MATCH(1,1/((A2=$A$2:$A$7)*(B2=$B$2:$B$7)),0)=(ROW()-ROW($2:$2)+1),(ROW()-ROW($2:$2)+1),"").

    The second formula sorts that resulting helper column rows ascending as you fill / copy downward with SMALL($C$2:$C$7,(ROW()-ROW($2:$2)+1)) and passes those row numbers to


    INDEX(A$2:A$7,SMALL($C$2:$C$7,(ROW()-ROW($2:$2)+1))). Filled across A$2:A$7 becomes B$2:B$7.


    Use the F9 function key to analyze nearly any formula, or the Evaluate Formula feature in the FORMULAS ribbon. These are among your best friends and teachers in Excel.

    Has this helped?

+ 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. Erase the unique combinations
    By antchh111 in forum Excel General
    Replies: 8
    Last Post: 07-03-2014, 07:48 PM
  2. [SOLVED] Unique Combinations from 4 Columns
    By ayvee0 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-12-2013, 06:44 PM
  3. Unique combinations of 7
    By ricardojaworski in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2013, 11:56 AM
  4. Unique Combinations List
    By tonynap in forum Excel General
    Replies: 1
    Last Post: 10-17-2012, 04:00 AM
  5. [SOLVED] Getting all unique combinations with in a collection?
    By manicPsyche in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2012, 01:01 PM
  6. Finding unique combinations
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2012, 11:40 AM
  7. Counting Unique combinations
    By t8jones in forum Excel General
    Replies: 9
    Last Post: 08-11-2010, 12:03 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