Explanation

This formula is a standard version of INDEX + MATCH with a small twist.

Working from the inside out, MATCH is used find the correct row number for the value in F4, 2100. Without the third argument, match_type, defined, MATCH defaults to approximate match and returns 2.

The small twist is that we add 1 to this result to override the matched result and return 3 as the row number for INDEX.

With level (C5:C9) supplied as the array, and 3 as the row number, INDEX returns “Gold”:

=INDEX(level,3) // returns Gold

Another option

The above approach works fine for simple lookups. If you want to use MATCH to find the “next largest” match in more traditional way, you can sort the lookup array in descending order, and use MATCH as described on this page .

Explanation

The example shown contains almost 10,000 rows of data. The data represents temperature readings taken every 2 minutes over a period of days. For any given date (provided in cell H7), we want to get the maximum temperature on that date.

Inside the IF function , logical test is entered as B5:B9391=H7. Because we’re comparing the value in H7 against a range of cells (an array), the result will be an array of results, where each item in the array is either TRUE or FALSE. The TRUE values represent dates that match H7.

For the value if true, we provide the range E5:E9391, which fetches all the full set of temperatures in Fahrenheit. This returns an array of values the same size as the first array.

The IF function acts as a filter. Because we provide IF with an array for the logical test, IF returns an array of results . Where the date matches H7, the array contains a temperature value. In all other cases, the array contains FALSE. In other words, only temperatures associated with the date in H7 survive the trip through the IF function.

The array result from the IF function is delivered directly to the MAX function , which returns the maximum value in the array.

With MAXIFS

In Excel O365 and Excel 2019, the new MAXIFS function can find the maximum value with one or more criteria without the need for an array formula. With MAXIFS, the equivalent formula for the this example is:

=MAXIFS(E5:E9391,B5:B9391,H7)

Explanation

The default behavior of the MATCH function is to match the “next smallest” value in a list that’s sorted in ascending order. Essentially, MATCH moves forward in the list until it encounters a value larger than the lookup value, then drops back to the previous value.

So, when lookup values are sorted in ascending order, both of these formulas return “next smallest”:

=MATCH(value,array) // default
=MATCH(value,array,1) // explicit

However, by setting match type to -1, and sorting lookup values in descending order, MATCH will return the next largest match. So, as seen in the example:

=MATCH(F6,length,-1)

returns 4, since 400 is the next largest match after 364.

Find associated cost

The full INDEX/MATCH formula to retrieve the associated cost in cell F8 is:

=INDEX(cost,MATCH(F6,length,-1))