I’ve found a number of threads to return the next largest number from a column and have obtained that using a combination of index, match, small and rank functions. However, I only want to return values from rows below a specified row.
Below is an example table. I’d like to return 12 from here when trying to obtain the next largest value after L2’s 278.
contract | qty |
---|---|
L 1 | 25 |
L 2 | 278 |
L 3 | 12 |
L 4 | 6 |
It is not possible to remove unwanted rows from the table as this is a constantly refreshing table of available data.
I used:
=INDEX(Table1[contract],MATCH(IFERROR(SMALL(Table1[qty],RANK.EQ(VLOOKUP(“L2”,Table1[[contract]:[qty]],2, FALSE),Table1[qty],1)+1,SMALL(Table1[qty],RANK.EQ(VLOOKUP(“L2”,Table1[[contract]:[qty]],2, FALSE),Table1[qty],1)-1)),Table1[qty],0)
This formula:
=MAX(INDEX(A2:B8,MATCH(D1,A2:A8,0)+1,2):B8)
the cell address B8 is to be replaced the last cell address in column B.
A2:B8 and A2:A8 are the respective ranges of data and column A.