+ Reply to Thread
Results 1 to 10 of 10

Retrieve Unique values from 2 columns

  1. #1
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Retrieve Unique values from 2 columns

    Hello Team,

    I want a formula to retrieve unique values from combination of 2 columns. Below is the screenshot.

    Order # Part # Answer
    1 p1 p1
    1 p2 p3
    2 p1 p4
    3 p3
    4 p2
    5 p4

    As you can see from the above screenshot, my requirement is to retrieve only p1, p3 and p4.

    Really appreciate any help!!!

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

    Re: Retrieve Unique values from 2 columns

    With data in columns A:B and headers in row 1 try array entering this formula in C2 and fill down until you get blanks. 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.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It works at my end.
    Dave

  3. #3
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Retrieve Unique values from 2 columns

    @ FlameRetired

    Thank you so much it worked like a charm!!!

    But when I enter p2 for Order 5 the formula does not return any value and it will be blank, any idea why is it so ?

  4. #4
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Retrieve Unique values from 2 columns

    @ FlameRetired

    Thank you so much it worked like a charm!!!

    But when I enter p2 for Order 5 the formula does not return any value and it will be blank, any idea why is it so ?

  5. #5
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Retrieve Unique values from 2 columns

    @ FlameRetired

    One more thing, the screenshot what I had posted is just an example. Let me put the real example as it might give more understanding of the problem.

    Order# Part # Answer
    44384 4183682 4183682
    42525 5095769 5095769
    42525 5095769 4811673
    44284 4811673
    42780 5095769

    As you can see from the above, 5095769 part# is repeating for multiple Order# hence we would be considering it only once. Here we always have to check if Part# which we consider has repeated for some other Order# then we will consider that Part# only once.
    Hope I'm clear in explaining this.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Retrieve Unique values from 2 columns

    Try this...

    Data Range
    A
    B
    C
    1
    Order#
    Part #
    Answer
    2
    44384
    4183682
    4183682
    3
    42525
    5095769
    5095769
    4
    42525
    5095769
    4811673
    5
    44284
    4811673
    6
    42780
    5095769
    7


    This array formula** entered in C2:

    =IFERROR(INDEX(B$2:B$6,MATCH(0,COUNTIF(C$1:C1,B$2:B$6),0)),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Retrieve Unique values from 2 columns

    @ Tony,

    Thank you so much for the suggestion and this works great but when I change the Part # 5095770 for Order#42525 it gives me wrong results.

    Below is the example:-

    Order# Part # Answer
    44384 4183682 4183682
    42525 5095769 5095769
    42525 5095770 5095770
    44284 4811673 4811673
    42780 5095769

    Scenario:- If Order# 42525 has 2 different Part# (5095769 & 5095770) then we should consider only one Part# (5095769 or 5095770) and the considered Part# 5095769 can be repeating for some other Order# 42780 but we will consider that Part# only once.

    so from the above example we should be expecting answer like:-
    Answer
    4183682
    5095769
    4811673

    Hope this example gives a clear picture!!!

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Retrieve Unique values from 2 columns

    This seems to do what you want...

    Data Range
    A
    B
    C
    1
    Order#
    Part #
    Answer
    2
    44384
    4183682
    4183682
    3
    42525
    5095769
    5095769
    4
    42525
    5095770
    4811673
    5
    44284
    4811673
    6
    42780
    5095769
    7


    This array formula** entered in C2:

    =IFERROR(INDEX(B$2:B$6,SMALL(IF(FREQUENCY(MATCH(A$2:A$6,A$2:A$6,0),ROW(A$2:A$6)-ROW(A$2)+1),IF(COUNTIF(C$1:C1,B$2:B$6)=0,ROW(B$2:B$6)-ROW(B$2)+1)),1)),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.

  9. #9
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Retrieve Unique values from 2 columns

    @ Tony,

    You are brilliant, this works perfectly!!!

    Meanwhile I tried to apply Vlookup formula which also works but not sure if itis right logic.

    Thank you so much!!!

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Retrieve Unique values from 2 columns

    You're welcome. Thanks for the feedback!

+ 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. variable formula to retrieve unique values from multiple criteria
    By deanusa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-22-2016, 05:13 PM
  2. Retrieve Unique values in two columns
    By laansesu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-04-2015, 07:22 AM
  3. Replies: 3
    Last Post: 05-29-2015, 04:20 PM
  4. Replies: 7
    Last Post: 06-27-2014, 02:26 AM
  5. Replies: 3
    Last Post: 12-13-2011, 08:00 AM
  6. retrieve unique data with duplicate values.
    By yrndtn in forum Excel General
    Replies: 0
    Last Post: 03-06-2011, 08:40 AM
  7. Retrieve non-unique values
    By alfredkri in forum Excel General
    Replies: 2
    Last Post: 12-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