+ Reply to Thread
Results 1 to 16 of 16

Formula to find 2nd Match using Index and 2 Match conditions

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Smile Formula to find 2nd Match using Index and 2 Match conditions

    Hi all,

    Looking for some help on using Index & Match where the there are more than 1 match for some of the data...

    =INDEX('Data 1'!$A$1:$T$15,MATCH($A$2,'Data 1'!$A$1:$A$15,0),MATCH($B$1,'Data 1'!$A$1:$T$1,0))

    I use the above Index and double Match Formula to match a Name in cell A2 and then to match a 2nd field in cell B1 – using Outlook 2007

    This works fine however in a couple of exceptions the 2nd field (B1) appears more than once in the row ($A$1:$T$1) so it returns the 1st match that it finds.

    Is there a tweak I could use to find the 2nd / 3rd match of the 2nd field (C3) – by this I do mean that I want the 1st match in one cell (using existing formula above) but then amend the formula in my next cell so that then returns the 2nd match of the 2nd field (whilst still matching the 1st field (A2)).

    Any guidance would be much appreciated
    Attached Files Attached Files
    Last edited by Cra5h; 05-24-2016 at 11:44 AM. Reason: solved

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Can you explain (or upload a new file) showing your desired outcomes? What results do you want populated and where do you want them populated?

  3. #3
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Basically on the sheet entitled master I would want a formula in C2 that would return the value 33.2% from the 'Data 1' sheet --> (i.e. the 2nd match of cell B1 ("% closed Early") and then in D2 a formula that would return the value 34.7% (i.e. the 3rd match of the data in cell B1 ("% closed Early") .

    Hope that makes sense...

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Try the formula below in B2 of your 'Master' sheet. Confirm it with Ctrl + Shift + Enter instead of the usual enter, then fill down through B12, then across through column E. I think it does what you're looking for.

    =IF(ISERROR(INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN()-1))),"",INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN()-1)))

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Quote Originally Posted by cantosh View Post
    =IF(ISERROR(INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN()-1))),"",INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN()-1)))
    The OP's profile says they're using Excel 2007 so you can use the IFERROR function and reduce the formula length by half:

    =IFERROR(INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN()-1)),"")

    Still array entered.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Nice catch, thanks! Old habits die hard, especially on Friday afternoons.

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions



    ---------

  8. #8
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Works perfectly so thanks - much appreciated.

    Is it possible to briefly explain how this works (i.e. what the formula is doing to get the correct answer) - I understand the IF ERROR part and the index Match but don;t understand how the SMALL,IF AND COLUMN BITS get me to the answer..

    Thanks Dave

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Another way.

    =INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),MATCH($B$1,'Data 1'!$A$1:$T$1,0)+(COLUMNS($B:B)-1)*4)
    Dave

  10. #10
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Hi, both of these work (so thanks for help) however as they use the "column()" they will only work if they are all located in the cells next door to each other (i.e. if I enter formula in 1st cell and then drag across). My spreadsheet is large and the cells that i want use to find 1st match and then then 2nd match are not located next to each other. Is there an alternative to using column so i can still find the nth match of my Index match but without using the column() where the cells have to be next door to each other.

    Hope that makes sense & any help would be gratefully appreciated....

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Is there an alternative to using column so i can still find the nth match of my Index match but without using the column() where the cells have to be next door to each other.
    Yes.

    You'll need to array-enter this one.

    I inserted / deleted some of the "various" columns in the attached to test it.


    =INDEX('Data 1'!$A$1:$V$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$B$1:$V$1="% closed Early",COLUMN('Data 1'!$B:$V)),COLUMNS($B:B)))

  12. #12
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    =IFERROR(INDEX('Data 1'!$A$1:$T$15,MATCH($A2,'Data 1'!$A$1:$A$15,0),SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN(A:A))),"")

    The version above (still entered w/Ctrl + Shift + Enter) still uses COLUMN, but should be a little more versatile than COLUMN()-1. When filled right, you'll have COLUMN(A:A) in the first column, returning the first result, COLUMN(B:B) in the second column returning the second result, etc. This will happen regardless of where your first column actually is. If you aren't returning the nth results in order left to right, you can modify the letters in COLUMN to suit your needs, e.g. COLUMN(H:H) returns the 8th result.

    To address your earlier question:
    IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1))
    This section says "If the header in 'Data 1' matches this column's header, return that column identifier", then
    SMALL(IF('Data 1'!$A$1:$T$1=B$1,COLUMN('Data 1'!$A$1:$T$1)),COLUMN(A:A) says to look at the Nth smallest column number that matches, so COLUMN(A:A) returns the first column that matches, B:B returns the second, etc. That return then tells the INDEX part of the formula to run the INDEX/MATCH result in that particular column. Hope this helps?

  13. #13
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    =IFERROR(INDEX('DATA'!$D$3:$DD$1000,MATCH($S$2,'DATA'!$D$3:$D$1000,0),SMALL(IF('DATA'!$D$3:$DD$3=$S$9,COLUMN('DATA'!$D$3:$DD$3)),COLUMN(A:A))),"")

    This is my adjusted formula (now in larger spreadsheet so differs from sample) where the Matches are based on Names in cells S2 and then S9. However once I have input the formula into my 1st cell (using “A:A”) the 1st cell seems to find the 2nd match – not 1st match??

    Have I input this incorrectly or can you possibly explain what’s going wrong?

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Try this...

    =IFERROR(INDEX('DATA'!$D$3:$DD$1000,MATCH($S$2,'DATA'!$D$3:$D$1000,0),SMALL(IF('DATA'!$D$3:$DD$3=$S$9,COLUMN('DATA'!$D$3:$DD$3)-COLUMN('DATA'!$D$3)+1),COLUMNS($A1:A1))),"")

    Still array entered!

  15. #15
    Registered User
    Join Date
    07-11-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    Thanks Tony- that seems to do the trick....

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

    Re: Formula to find 2nd Match using Index and 2 Match conditions

    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. MATCH and INDEX to find most recent date and other conditions
    By vwlibra in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-09-2016, 08:05 PM
  2. Help with Index/Match Formula-two conditions and return multiple items
    By bigermac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-08-2015, 11:06 AM
  3. Replies: 2
    Last Post: 12-18-2014, 09:52 AM
  4. IF formula with multiple conditions using INDEX/MATCH
    By cad1llac in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-05-2013, 06:32 AM
  5. Replies: 13
    Last Post: 12-13-2012, 11:44 AM
  6. Replies: 5
    Last Post: 02-29-2012, 08:51 PM
  7. INDEX/MATCH/MATCH (2 Conditions for Column #)
    By ron2k_1 in forum Excel General
    Replies: 4
    Last Post: 02-23-2011, 03:11 PM

Tags for this Thread

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