Index Match lookup matching multiple criteria and partial text string

ripina

New Member
Joined
Nov 2, 2015
Messages
14
I need to first match the ID, then the VENDOR, and if the TYPE contains the words "next", then give me the largest (MAX) of the values matched. In some instances TYPE matches twice, in others one, and others none.
Ideally this would be in formula format, I can't add macros/VBA to the file.

I have tried two formulas, both with no good result, FYI, the data is formatted as a table and named DataTable.
I tried: '{=LARGE(IF(DataTable[TYPE]="*next*",INDEX(DataTable[VALUE],MATCH(1,(DataTable[ID]=G4)*(DataTable[VENDOR]=G5),0)),"not found"),1}
and I also tried: '{=LARGE(IF((DataTable[ID]=G11)*(DataTable[VENDOR]=G12)*(DataTable[TYPE]="*next*"),DataTable[VALUE],""),ROW($A$2))}
Neither of these work for me.
IDVENDORTYPEVALUEEXAMPLE 1: LOOKUP RESULT
2​
ACMEFTL other
1.18​
ID2
2​
ACMESix next-day
1.25​
VENDORBELFRY
2​
ACMEtwo next day
1.25​
TYPE*next*
2​
ACMEmixed
1.25​
VALUE
1.12​
<---correct answer from formula should be
2​
BELFRYFTL other
1.05​
2​
BELFRYSix next-day
1.08​
2​
BELFRYtwo next day
1.12​
EXAMPLE 2: LOOKUP RESULT
2​
CROSSFTL other
1.01​
ID2
2​
CROSSSix next-day
1.09​
VENDORACME
2​
CROSStwo next day
1.15​
TYPE*next*
2​
DINGOFTL other
1.01​
VALUE
1.25​
<---correct answer from formula should be
2​
DINGOFTL mixed
1.09​
even though both "next" matches are the same "1.25"
2​
DINGOtwo next day
1.15​
EXAMPLE 3: LOOKUP RESULT
ID2
VENDORDINGO
TYPE*next*
VALUE
1.15​
<---correct answer from formula should be
even though there is only one "next" day match


Any help is greatly appreciated. Image attached with the scenario.
 

Attachments

  • ExcelScenario.JPG
    ExcelScenario.JPG
    137.8 KB · Views: 13

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try this

Dante Amor
ABCDEFGHI
1IDVENDORTYPEVALUEIDVENDORTYPEVALUE
22ACMEFTL other1.182BELFRYnext1.12
32ACMESix next-day1.252ACMEnext1.25
42ACMEtwo next day1.252DINGOnext1.15
52ACMEmixed1.252CROSSnext1.15
62BELFRYFTL other1.05
72BELFRYSix next-day1.08
82BELFRYtwo next day1.12
92CROSSFTL other1.01
102CROSSSix next-day1.09
112CROSStwo next day1.15
122DINGOFTL other1.01
132DINGOFTL mixed1.09
142DINGOtwo next day1.15
S2
Cell Formulas
RangeFormula
I2:I5I2=LOOKUP(2,1/((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE]))),Table1[VALUE])
 
Upvote 0
Try this. depending on your version of Excel, it might need to be invoked with Ctrl+Shift+Enter.

=MAX(IFERROR(SEARCH(G6,DataTable[TYPE]),0)*(DataTable[VENDOR]=G5)*DataTable[VALUE])
 
Upvote 0
Try this. depending on your version of Excel, it might need to be invoked with Ctrl+Shift+Enter.

=MAX(IFERROR(SEARCH(G6,DataTable[TYPE]),0)*(DataTable[VENDOR]=G5)*DataTable[VALUE])

Unfortunately this doesn't work, I keep receiving an error. Also is it not missing the second part for "IFERROR"?
 
Upvote 0
Try this

Dante Amor
ABCDEFGHI
1IDVENDORTYPEVALUEIDVENDORTYPEVALUE
22ACMEFTL other1.182BELFRYnext1.12
32ACMESix next-day1.252ACMEnext1.25
42ACMEtwo next day1.252DINGOnext1.15
52ACMEmixed1.252CROSSnext1.15
62BELFRYFTL other1.05
72BELFRYSix next-day1.08
82BELFRYtwo next day1.12
92CROSSFTL other1.01
102CROSSSix next-day1.09
112CROSStwo next day1.15
122DINGOFTL other1.01
132DINGOFTL mixed1.09
142DINGOtwo next day1.15
S2
Cell Formulas
RangeFormula
I2:I5I2=LOOKUP(2,1/((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE]))),Table1[VALUE])

This works great! I'm going to apply it to my actual data and see how it performs. Thanks for the quick reply.
 
Upvote 0
Which version of Excel are you using?

The IFERROR function has a 0 as its condition argument.
 
Upvote 0
Thanks DanteAmor, fomrula works perfectly. I'm going to research the Lookup and Search formulas to learn how they function. Would you be able to share how it works, I want to learn, not just copy and paste formulas. Thanks again.
 
Upvote 0
=LOOKUP(2,1/((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE]))),Table1[VALUE])

1. When the data is ordered, from least to greatest, if the LOOKUP function does not find the value, then it returns the last value of the data.

SEARCH(H2,Table1[TYPE])

2. Search, look for "next" in the column "TYPE", if it finds it, it returns a number, if it doesn't find it, it returns the error: #!Value!

3. Using the LOOKUP formula in this way "Lookup (2,1 / ...)" turns it into an array formula, that is, an array formula is a formula that can perform multiple calculations on one or more of the items in an array.

4. ((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE])) , This compares the ID with F2, the vendor with G2 and type with H2, the values that match are TRUE and those that do not match are FALSE.

5. TRUE results are converted to 1 and FALSE values are converted to 0.
6. 1/((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE]))) , 1 Divide the results TRUE or FALSE

That's
= 1/TRUE, 1/FALSE
= 1/1, 1/0
= 1/1 = 1, 1/0 = Error "#¡DIV/0!"

7. LOOKUP(2,1/((Table1[ID]=F2)*(Table1[VENDOR]=G2)*(SEARCH(H2,Table1[TYPE]))),Table1[VALUE]) Then look for the 2 in the (#¡DIV/0!, 1) vector and since it doesn't find it, then it takes the last value, in this case take the last 1.

8. Finally take the last position of the resulting vector.

I hope it helps.
 
Last edited:
Upvote 0
Thank you very much, great explanation. I wasn't sure what the "2,1" at the beginning of the Lookup formula was doing. Very insightful, I may be able to use this for other tasks. Thanks again.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,538
Members
449,038
Latest member
Guest1337

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