INDEX MATCH, but I need it to pull multiple results

Zanith

New Member
Joined
Feb 12, 2013
Messages
21
Hi all,

I'm running into an issue with some lookup I'm doing using INDEX MATCH which are stopping after they find the first result. I need this function to continue searching through the data for ALL possible matches to give me the result I need. I understand that an array formula is probably what I need, but I'm not certain and the work I've done so far to put one together has not worked properly.

The formula I'm using is as follows, and below is a rough idea of my table layout.

=IF(AND(INDEX('Cost Pool Account Set Line'!$B:$B,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))>=Summary!$A452,INDEX('Cost Pool Account Set Line'!$C:$C,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))<=Summary!$A452),"X","")

Summary = my "working" sheet which is summarizing the information.

Cost Pool Account Set Line = Table pulled in from power query on a separate sheet within the workbook


Summary Sheet Layout - I need the formula to identify that there are entries in the Cost Pool Account Set Line for LABOR not just for the 10000 (which it's doing now), but also 11000 and 11010.

NumberLABORFRINGE
10000X
10100X
11000X
11010X

<tbody>
</tbody>


Cost Pool Account Set Line

From AccountTo AccountCost Pool Account Set Name
1000010099LABOR
1010010100FRINGE
1099911999LABOR

<tbody>
</tbody>


The formula above may be overly cumbersome for what I'm trying to achieve, if there are simplification suggestions I'm happy to hear them!

Hopefully this make some sense, if not please let me know if there is additional information I can provide to help.

Thank you!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try this:


Excel 2010
ABCDEFG
1NumberLABORFRINGEFrom AccountTo AccountCost Pool Account Set Name
210000X1000010099LABOR
310100X1010010100FRINGE
411000X1099911999LABOR
511010X
Sheet1
Cell Formulas
RangeFormula
B2=IF(COUNTIFS($E:$E,"<="&$A2,$F:$F,">="&$A2,$G:$G,B$1),"X","")
 
Upvote 0
Maybe with Vlookup, like this.


Book1
ABC
22NumberLABORFRINGE
2310000LABOR
2410100FRINGE
2511000LABOR
2611010LABOR
27
28
29Cost Pool Account Set Line
30
31From AccountTo AccountCost Pool Account Set Name
321000010099LABOR
331010010100FRINGE
341099911999LABOR
Blad1
Cell Formulas
RangeFormula
B23=VLOOKUP(A23,$A$32:$C$34,3,1)
 
Upvote 0
Try this:


Worksheet Formulas
CellFormula
B2=IF(COUNTIFS($E:$E,"<="&$A2,$F:$F,">="&$A2,$G:$G,B$1),"X","")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Thanks for the response 63falcondude. I took my original formula:

=IF(AND(INDEX('Cost Pool Account Set Line'!$B:$B,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))>=Summary!$A452,INDEX('Cost Pool Account Set Line'!$C:$C,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))<=Summary!$A452),"X","")

And modified it using your suggestion to create the following:

=IF(COUNTIFS('Cost Pool Account Set Line'!$B:$B,">="&Summary!$A2,'Cost Pool Account Set Line'!$C:$C,"<="&Summary!$A2,'Cost Pool Account Set Line'!$D:$D,Summary!C$1),"X","")

I did swap the < and > signs as I need to look for the number in A2 and return an X only if it sits between the values of what's in column B and C within the Cost Pool Account Set Line. Unfortunately, this formula returning false values for me in cells where it should be returning true. In fact, I'm not getting any true values across the entire spreadsheet. Could you walk me through the thought process of the COUNTIFS above. That might help me.

Thank you!!
 
Upvote 0
Hi Oeldere,

I initially started down the vlookup road but was unable to get this working due to some of the criteria I needed to check against (is my lookup greater than this number over here, but less then this other number) and those limitations forced me to move to the INDEX MATCH formula in my OP which works, but is only returning to me the first result in situations where I know there are multiple hits.

If you have suggestions on how to make vlookup work in this situation I'd love to hear them.

Thanks!
 
Upvote 0
Sheet2 (data)

Row\Col
A​
B​
C​
2​
10000 10099 LABOR
3​
10100 10100 FRINGE
4​
10999 11999 LABOR

Sheet1 (processing)

Row\Col
A​
B​
C​
1​
Number LABOR FRINGE
2​
10000 X
3​
10100 X
4​
11000 X
5​
11010 X

In B2 control+shift+enter, not just enter, copy across, and down:

=IF(ISNUMBER(MATCH(1,(INDEX(IF(Sheet2!$C$2:$C$4=B$1,Sheet2!$A$2:$B$4,-9.99E+307),0,1)<=$A2)*(INDEX(IF(Sheet2!$C$2:$C$4=B$1,Sheet2!$A$2:$B$4,-9.99E+307),0,2)>=$A2),0)),"X","")
 
Upvote 0
Thanks for the response 63falcondude. I took my original formula:

=IF(AND(INDEX('Cost Pool Account Set Line'!$B:$B,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))>=Summary!$A452,INDEX('Cost Pool Account Set Line'!$C:$C,MATCH(Summary!C$1,'Cost Pool Account Set Line'!$D:$D,0))<=Summary!$A452),"X","")

And modified it using your suggestion to create the following:

=IF(COUNTIFS('Cost Pool Account Set Line'!$B:$B,">="&Summary!$A2,'Cost Pool Account Set Line'!$C:$C,"<="&Summary!$A2,'Cost Pool Account Set Line'!$D:$D,Summary!C$1),"X","")

I did swap the < and > signs as I need to look for the number in A2 and return an X only if it sits between the values of what's in column B and C within the Cost Pool Account Set Line. Unfortunately, this formula returning false values for me in cells where it should be returning true. In fact, I'm not getting any true values across the entire spreadsheet. Could you walk me through the thought process of the COUNTIFS above. That might help me.

Thank you!!

You have the inequalities backwards.
If A2 has to be between columns B and C (assuming that column B is "from account" and column C is "to account"), that means that B:B <= A2 <= C:C.

Also, make sure that your references are pointing to the correct cells (see example from post #2).
 
Upvote 0
I do not fully understand your needs. Perhaps you could break the problem down in to smaller pieces.

I think you are after a lookup formula with complex conditions. The below formula is one I have used in the past with great success thanks to this forum. I don’t full understand it but I believe that it turns each element in an array into true and false. Each condition narrows down the array until you are left with only one result.

=LOOKUP(2,1/((Array1=Lookup Value1)*(array2=lookup value2),result array)

Or with different operators

=LOOKUP(2,1/((Array1>=Lookup Value1)*(array2<=lookup value2),result array)

I hope that this is of some help.
 
Upvote 0
Thanks 63falcondude, I appreciate the clarification on the inequalities and it makes complete sense now.

To help my understanding I went and created the table in post #2 above and used the formula you provided. Worked like a charm.

I then went ahead and brought in a simplified version of some of my live data and structured it identically, used the same formula, and ran into the same problem on the simple sheet that I'm having on my primary spreadsheet.

I'm not sure what is going on here to cause it to work fine using the example, but not using my live data.

I've uploaded the spreadsheet I mentioned in this post with the copy of post #2 on sheet 1 and sheet 2 containing the same formula but I've brought in my data for the To/From and Cost Pool Account Set Name. If you would be able to look at this and tell me what I'm doing wrong I would very much appreciate it.

https://www.dropbox.com/s/rlxg1vzlza6qmbt/COST POOL MATRIX - HELPv3.xlsx?dl=0

Thank you!!
 
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

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