Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Managing Conditional Formatting Rules in Excel
  • How to combine 2 or more chart types in a single chart in Excel
  • Move chart to a separate worksheet in Excel
  • Calculate Conditional Percentile ‘IF’ in table in Excel
  • Get column index in Excel Table

References

  • How to use Excel INDIRECT Function
  • How to get first row number in range in Excel
  • Lookup entire row in Excel
  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions
  • Approximate match with multiple criteria in Excel

Data Validations

  • Excel Data validation exists in list
  • Excel Data validation don’t exceed total
  • Excel Data validation whole percentage only
  • Excel Data validation only dates between
  • Excel Data validation must contain specific text

Get nth match with INDEX / MATCH in Excel

by

This tutorial shows how to Get nth match with INDEX / MATCH in Excel using the example below;

Formula

{=INDEX(array,SMALL(IF(vals=val,ROW(vals)-ROW(INDEX(vals,1,1))+1),nth))}

Explanation

To retrieve multiple matching values from a set of data with a formula, you can use the IF and SMALL functions to figure out the row number of each match and feed that value back to INDEX. In the example shown, the formula in I7 is:

{=INDEX(amts,SMALL(IF(ids=id,ROW(ids)-ROW(INDEX(ids,1,1))+1),H6))}

Where named ranges are amts (D4:D11), id (I3), and ids (C4:C11).

Note that this is an array formula and must be entered with Control + Shift + Enter.

How this formula works

At the core, this formula is simply an INDEX formula that retrieves the value in an array at a given position. The value for n  is supplied in column H, and all the “heavy” work that the formula does is to figure out the row from which to retrieve a value, where row corresponds to “nth” match.

The IF function does the work of figuring out which rows contain a match, and the SMALL function returns the nth value from that list. Inside of IF, the logical test is:

ids=id

which yields this array:

{TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE}

Note the customer id matches at the 1st and 4th positions, which appear as TRUE. The “value if true” argument in IF generates a list of relative row numbers with this expression:

ROW(ids)-ROW(INDEX(ids,1,1))+1

which produces this array:

{1;2;3;4;5;6;7}

This array is then “filtered” by the logical test results, and the IF function returns the following array result:

{1;FALSE;FALSE;4;FALSE;FALSE;FALSE}

Note we have valid row numbers for row 1 and row 2.

This array is then processed by SMALL, which is configured to use values in column H to return “nth” values. The SMALL function automatically ignores the logical values TRUE and FALSE in the array. In the end, the formulas reduce to:

=INDEX(amts,1) // I6, returns $150
=INDEX(amts,4) // I7, returns $125

Handling errors

Once there are no more matches for a given id, the SMALL function will return a #NUM error. You can handle this error with the IFERROR function, or by adding logic to count matches and abort processing once the number in column H is greater than the match count. The example here shows one approach.

Post navigation

Previous Post:

COSH function: Description, Usage, Syntax, Examples and Explanation

Next Post:

Excel Data validation require unique number

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • IFS function: Description, Usage, Syntax, Examples and Explanation
  • How to return blank in place of #DIV/0! error in Excel
  • How to use Excel AND Function
  • Not Equal To ‘<>‘ operator in Excel
  • Extract multiple matches into separate rows in Excel

Date Time

  • Get work hours between dates and times in Excel
  • ISOWEEKNUM function: Description, Usage, Syntax, Examples and Explanation
  • How to get same date next month or previous month in Excel
  • HOUR function: Description, Usage, Syntax, Examples and Explanation
  • Get project end date in Excel

Grouping

  • Running count group by n size in Excel
  • Group arbitrary text values in Excel
  • Group numbers at uneven intervals in Excel
  • How to randomly assign data to groups in Excel
  • If cell contains one of many things in Excel

General

  • Create dynamic workbook reference to another workbook in Excel
  • How to generate random number weighted probability in Excel
  • Transpose: Switch ‘Rows to Columns’ or ‘Columns to Rows’ in Excel
  • How to calculate percent of students absent in Excel
  • 3D SUMIF for multiple worksheets in Excel
© 2026 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning