I have seen various topics that have dealt with this issue at least in part, but I am still having difficulty achieving the desired result. I am starting with a range A4:B18 that contains the names of 15 stores and their monthly sales and am attempting to return the top and bottom 5, displaying store name and # of sales in adjacent cells. I want to include duplicates. I have 15 in E1 and in E2 the formula below and copied down.
In F4 I have the formula below and copied down:
This works great for the top 5, but I run into a problem with the Bottom 5. The formula below returns the bottom 5 sales numbers in reverse order with no problem:
However, I cannot seem to get the corresponding bottom 5 stores in reverse order. What would I need to change below? As is it returns the top 5 as above.
Code:
=IF(ROWS(E$4:E4)<=$E$2,LARGE($B$4:$B$18,ROWS(E$4:E4)),"")
Code:
{=IF(N($E$4),INDEX(A$4:A$18,SMALL(IF(B$4:B$18=E4,ROW(B$4:B$18)-ROW(B$4)+1),COUNTIF(E$4:E4,E4))),"")}
Code:
=IF(ROWS(H$4:H4)<=$E$2,SMALL($B$4:$B$18,ROWS(H$4:H4)),"")
Code:
{=IF(N($E$4),INDEX(A$4:A$18,SMALL(IF(B$4:B$18=E4,ROW(B$4:B$18)-ROW(B$4)+1),COUNTIF(E$4:E4,E4))),"")}