+ Reply to Thread
Results 1 to 31 of 31

Get nth match with INDEX/MATCH with multiple criteria

  1. #1
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Get nth match with INDEX/MATCH with multiple criteria

    Hi,

    I'm trying to add multiple criteria to the formula I found on a website.
    {=INDEX(array,SMALL(IF(vals=val,ROW(vals)-ROW(INDEX(vals,1,1))+1),nth))}

    For their example, this formula translates to {=INDEX(amts,SMALL(IF(ids=id,ROW(ids)-ROW(INDEX(ids,1,1))+1),H6))}

    This formula works for me, but now I would like to add 2 more criteria. One that the number has to be bigger than or equal to a threshold and one that the number has to be smaller than or equal to another threshold.

    The website says I have to look at boolean logic and gives a link to this function {=INDEX(range1,MATCH(1,(A1=range2)*(B1=range3)*(C1=range4),0))}
    Which translates to this formula in their example {=INDEX(E5:E11,MATCH(1,(H5=B5:B11)*(H6=C5:C11)*(H7=D5:D11),0))}
    but the function on there doesn't let me get the nth match, only the first.

    I'm looking for a way to combine both functions, so I can have multiple criteria, but still get the nth outcome.

    Kind regards,

    Matt
    Last edited by MattRoux; 08-06-2019 at 11:02 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    You might want to have a quick look at this (it suggests using AGGREGATE): https://stackoverflow.com/questions/...function-excel
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Hi Ali,

    Thanks a lot for your reply!
    I got the numbers to work, however, I also have some cells that I want to display text in for the cell that matches the criteria and those cells get a #NUM! error.
    Do you know how to solve this by any chance?

    Kind regards,

    Matt

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Can you share a sample workbook so that we can help resolve this?

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  5. #5
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I hope I did it right, it should be attached now.

    What I also noticed is that the results it gives me are largest to smallest for every single column in there, so the rows are not linked to each other anymore.

    An example would be that the date 25-7-2019 should not be linked to the EV of 159 million. The data can be found in the other tab.


    Kind regards,


    Matt
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Dear Ali,

    Did you get the chance to have a look at the sample workbook?

    Kind regards,

    Matt

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

    Re: Get nth match with INDEX/MATCH with multiple criteria

    No - I didn't see it. I'll have a look now and see if I can help.

  8. #8
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Thanks a lot, I really appreciate your help!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Here's the problem:

    Excel 2016 (Windows) 32 bit
    A
    10
    5
    11
    4
    12
    3
    13
    2
    14
    1
    15
    6
    16
    7
    17
    8
    18
    9
    19
    10
    Sheet: Sheet1

    The formula needs these values to be in order. Yours go from 1 to 10 in the middle - this won't work.

  10. #10
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I did that, but it won't change the answers.
    I found a mistake on my side as well, and corrected that, so I will put the updated file in the attachments.

    What I see happen is that for each category I'm looking at, it chooses the lowest value individually, instead of linking a full row and showing the related info.
    The second thing I'm still struggling with is that the function as it is right now only shows number, but not text, and I would like to see the related text of the data file as well if possible.

    For example, if you look at row 10, it gives the date 3-5-2019 and shows an ev/ebitda of 4,81 and an ev of 2.470.000. But if we look at the data tab, the dat 3-5-2019 should have an ev/ebitda of 14,48 and an ev of 7.500.000.

    Kind regards,

    Matt
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Forget the formulae for a moment - explain IN WORDS what the purpose of your summary sheet is.

    We are dealing with a matrix of incorrect answers and errors at the moment - ideally you should mock up manually your EXPECTED RESULTS and explain why you expect them.

  12. #12
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Alright, you can find the expected output and the explanation in words in the file in the attachments.


    I hope this makes things more clear.


    And again, I really appreciate the effort you put into helping me, thanks so much!


    Kind regards,

    Matt
    Attached Files Attached Files

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Could dates ever be repeated in the source table? I'm guessing they could. If so, what is the second level identifier for each row?

    I am ignoring your explanation in the workbook because you are still fixating on an anticipated formula instead of explaining simply what the objective is. I only have so many hours a day to spend on helping here, so I like to cut to the chase.

    Is the objective simply to display the data in date order?

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    By the way, please update your user profile to tell us WHICH VERSION of Excel you are using.

  15. #15
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    The objective is to display the data in the order of the data file.
    So if I would change the order in the data file, the order of the output would change as well.

    The date repetition shouldn't be a problem, because we are looking for the nth match in the data file match starting from row 1 and going down.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    OK - I think I get it now.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I think, from what you have said, this is all you need:

    =INDEX(Data!A$2:A$10,Sheet1!$A26)

    EDIT: Or not ...

    The penny has just dropped. Why don't you just use a slicer on the datasheet?

  18. #18
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    That's already a big step in the right direction, thanks. The only thing I'm looking for after this is how to include the 'filter' of the sub industry (B6) and the deal size range (H5;J5).

  19. #19
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I don't use slicers, as in the original file the data will be in a different file, which will not be accessible for other people using it. This is just a small summary version, the real file will have 5000+ rows with data ranging over 10 years and about 80 different sub industries which can be selected with a dropdown menu (B6).


    That's the reason I would like to have the filters in the formula.

    EDIT:
    To give some more context, the aim is to make the model as easy as possible to use for people who haven't worked on making it, so they literally just need to give the sub industry they are interested in and the range of deal size ev
    Last edited by MattRoux; 08-05-2019 at 07:07 AM.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    OK - this seems to me the ideal scenario for PowerQuery to deal with, but I have run out of time just now. If some other PQ expert like Olly doesn't step in, I'll try and have a look later on, but I have to go out for a while now.

  21. #21
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Alright, thanks!

  22. #22
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I'll leave PQ to Ali, but I've updated your sample file with a formula setup that I think is doing what you're asking for.

    I've inserted a new column A to hold a variation of the aggregate formula which identifies the rows of interest in the data sheet, then used index to pull the data into the table.

    I've made it as efficient as possible, but it will still be slow with 5k rows of data to process, so probably still a good idea to look into PQ.
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Edit: Misunderstood
    Last edited by MattRoux; 08-06-2019 at 09:48 AM.

  24. #24
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Hi Jason,

    I misunderstood/interpreted your response, this does turn out to be what I needed.

    Thank you so much, and sorry for the initial misunderstanding!

    Kind regards,

    Matt

  25. #25
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Get nth match with INDEX/MATCH with multiple criteria

    That is exacty what it does, as far as I can see, the results of the formula are a 100% match for your expected results.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Each of the 3 sections in bold forms a boolean logic test, the first checks that the GICS SubInd name is equal to C6, the second and third check that EV is greater than I5 and less than K5.

    If the results are wrong with different criteria then please provide an example of this.

  26. #26
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Ignore that, your last post and edit came through after I refreshed.

    I still think that PQ will be a better option for what you need, if it can do what is required. Hopefully someone else will be able to assist there.

    I'll give it a go later, but I have very little PQ experience so even if it is possible it might not be something that I can do.

  27. #27
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    The only thing that I had to do was -1 in the last part of the Index function (so e.g. $A10-1 instead of $A10), because for some reason in my main file (different from the small file you worked on) it gave the answer below the row given by your formula.
    Just as a quick check with you, does this sound right to you?

    It seems to work in my main file after the -1 adjustment .


    EDIT:
    The index function in the different categories, so e.g. for date or target. Not the new formula in column A you came up with.

  28. #28
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Is this sill ongoing or are you satisfied with the solution offered here?

  29. #29
    Registered User
    Join Date
    07-24-2019
    Location
    Netherlands
    MS-Off Ver
    Excel for office 365 ProPlus
    Posts
    24

    Re: Get nth match with INDEX/MATCH with multiple criteria

    I'm satisfied, thanks for your time. Really appreciate the effort and time you put it, as I know I wasn't the easiest person to deal with

  30. #30
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Get nth match with INDEX/MATCH with multiple criteria

    Did you use entire columns with Index, as I did with the formula in the sample file? If you used a limited range starting from row 2, then that would explain it.

  31. #31
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,804

    Re: Get nth match with INDEX/MATCH with multiple criteria

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Index and match - multiple possible match criteria
    By JDobbsy1987 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2017, 01:52 PM
  2. Need help in Index, Match usage to match multiple criteria in sum function
    By Summer0830 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2017, 02:47 AM
  3. Index/Match to Match entries on multiple criteria
    By manning457 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-06-2015, 02:32 PM
  4. [SOLVED] INDEX/MATCH with Multiple MATCH criteria ?
    By KomicJ in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-17-2015, 09:04 AM
  5. Replies: 2
    Last Post: 09-27-2014, 04:34 PM
  6. [SOLVED] Index Match using multiple criteria to match to
    By sacastiglia in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-25-2014, 03:46 PM
  7. Replies: 6
    Last Post: 04-30-2014, 02:42 AM

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