index/match duplicate value help (also with #N/A error

jeff106

New Member
Joined
Dec 2, 2016
Messages
21
ABCDE
1Store A95Store C91
2Store B#N/AStore C91
3Store C91Store E93
4Store D91
5Store E93

<tbody>
</tbody>

Hi All,
I have a sheet that is using index match to pull data (column B) and match it to restaurant names (Column A) from another sheet. However, in some instances there is no data for that restaurant so the index match returns #N/A.

I want to be able to then take that data an in a separate area show the bottom (and top) performing restaurants for that data. (Columns D & E). In cell E1, I am using this formula to show me the lowest number in column B (as long as its below 95 because stores performing above 95 shouldn't be listed in the "bottom performing" list).

=SMALL(IF(ISERROR(B1:B5), "", IF(B1:B5<=95,B1:B5,"")),1)

Cell E2 would use the same formula but change the "1" at the very end to 2 to show me the second smallest number. The IF ISERROR is helping me to ignore the #N/A when listing these numbers for me.

It works great. Now the next step is where I am having an issue. I would like D1 and D2 to show the Store Name that corresponds to those 2 lowest data values. When using index match however,

=INDEX($A$1:$A$5,MATCH($E1,$B$1:$B$5,0))
=INDEX($A$1:$A$5,MATCH($E2,$B$1:$B$5,0))

it only lists the first store name (Store C) twice since the 2 lowest values are equal instead of first and second lowest store names (Store C & D). I have researched several different solutions on the web like ranking the values before using index match. However, I can't use the rank feature because of the #N/A values.

Any idea how I can get the correct store names listed with the lowest values ?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this:

ABCDE
1Store A95Store C91
2Store B#N/AStore D91
3Store C91Store E93
4Store D91
5Store E93
6

<tbody>
</tbody>
Sheet5

Array Formulas
CellFormula
D1{=IF(E1<>"",INDEX($A$1:$A$5,SMALL(IF(ISNUMBER($B$1:$B$5),IF($B$1:$B$5=E1,ROW($B$1:$B$5)-ROW($B$1)+1)),COUNTIF($E$1:$E1,E1))),"")}
E1{=IFERROR(SMALL(IF(ISERROR($B$1:$B$5), "", IF($B$1:$B$5<95,$B$1:$B$5,"")),ROWS($E$1:$E1)),"")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>

Put those 2 array formulas in D1:E1, then copy down as needed.

Hope this helps.
 
Upvote 0
Try this:

ABCDE
1Store A95Store C91
2Store B#N/AStore D91
3Store C91Store E93
4Store D91
5Store E93
6

<tbody>
</tbody>
Sheet5

Array Formulas
CellFormula
D1{=IF(E1<>"",INDEX($A$1:$A$5,SMALL(IF(ISNUMBER($B$1:$B$5),IF($B$1:$B$5=E1,ROW($B$1:$B$5)-ROW($B$1)+1)),COUNTIF($E$1:$E1,E1))),"")}
E1{=IFERROR(SMALL(IF(ISERROR($B$1:$B$5), "", IF($B$1:$B$5<95,$B$1:$B$5,"")),ROWS($E$1:$E1)),"")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>

Put those 2 array formulas in D1:E1, then copy down as needed.

Hope this helps.


THIS SOLVED MY PROBLEM. THANK YOU!

PS. You saved the rest of my hair from being pulled out. :)
 
Upvote 0
Happy to help! :cool:

And I'm always glad to be part of the hair preservation team!
 
Upvote 0

Forum statistics

Threads
1,216,200
Messages
6,129,468
Members
449,511
Latest member
OttosArmy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top