Match column value with substring from reference table in Excel - excel

I have a reference table on sheet1
| A | B |
|---------------|----------|
| dog | 10 |
|---------------|----------|
| cat | 20 |
|---------------|----------|
I then have a list with values on sheet 2
| D | E |
|-------------------|----------|
| wild dog 2 | |
|-------------------|----------|
| strange cat Willy | |
|-------------------|----------|
I would like E to contain the value of B from the reference table, using the first substring match
I tried with VLOOKUP and INDEX ( MATCH ..) but this is not getting me anywhere. Help or pointers appreciated.

With your current sample data following formula will work. But don't know how is your actual data.
=INDEX($B$1:$B$10,MATCH(TRIM(MID(SUBSTITUTE(D1," ", REPT(" ",100)),100,100)),$A$1:$A$10,0))

I ended up using the formula from Harun24HR and simplifying it.
=(INDEX($B$1:$B$10;MATCH(1;COUNTIF(D1;"*" & $B$1:$B$10 & "*");0));

Related

Excel search multiples rows containing substring

I have an Excel file with 2 sheets :
The first one got a list of keywords in a column.
The second one got sentences on a column along with an id on another column.
Thus the 2 sheets look like this :
Sheet 1: Sheet 2:
A A B
| the | | 15587 | The cat is walking |
| cat | | 94683 | No one here |
| ... | | 47222 | The TV is on |
| 59378 | No cat allowed |
| ... | ... |
What I want to do is to put on the B column of sheet 1 the list of sentences ids where the keyword is found. So here I'll get on sheet 1 :
A B
| the | 15587;47222 |
| cat | 15587;59378 |
| ... | ... |
Do you know how I can achieve this using functions ? I tried VLOOKUP but it only returns the first occurrence and I don't know how to use FILTER with an operator to check if the sentence contain a string.
Thanks
You could try:
Formula in E1:
=TEXTJOIN(";",,FILTER(A$1:A$4,ISNUMBER(SEARCH(" "&D1&" "," "&B$1:B$4&" ")),""))

Excel Formula INDEX+AGREGATE+ORDER by another column

I have an excel formula that I need help with, since I'm not that savvy on excel.
The formula is the following:
=IFERROR(INDEX(Liste!$C$2:$N$10000,AGGREGATE(15,6,(ROW(Liste!$A$2:$A$10000)-ROW(Liste!$A$2)+1)/ISNUMBER(SEARCH("BOX"," " & Liste!$B$2:$B$10000 & " ")),ROWS($A$4:$A4)),COLUMN()-1),"")
This formula looks on another sheet (Liste) for lines containing the word BOX on column B and show them on "ROWS($D$4:$D4)" (in this case) starting from Column "C".
I'm not even sure if that formula orders the results on column "B" since they're all the same with the word "BOX".
It works prefectly, the only think I can't achieve (and I've tried diferent combinations) is to change that code to make it show the results in order according to column "C" (not column B).
Sample Data:
Sheet "Liste"
|-----------|----------|-----------|
| B | C | D |
|-----------|----------|-----------|
| NOTBOX | 5 | SAMPLE |
| BOX | 3 | SAMPLE |
| BOX | 1 | SAMPLE |
| BOX | 2 | SAMPLE |
| NOTBOX | 4 | SAMPLE |
|-----------|----------|-----------|
Current Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 3 | SAMPLE |
| 1 | SAMPLE |
| 2 | SAMPLE |
|-----------|----------|
Desired Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 1 | SAMPLE |
| 2 | SAMPLE |
| 3 | SAMPLE |
|-----------|----------|
Can someone give me a hand?
One thing I forgot to state is that I need to drag this formula around (rows and columns) so it's important that I can drag it on a large zone (if lines are added in the future) and that it ignores the errors (blank).
Thank you in advance
Here is an example on how you could do this:
Formula in F2:
=SMALL(IF($A$2:$A$6=$E$2,$B$2:$B$6,""),ROW(A1))
Or in French
=PETITE.VALEUR(SI($A$2:$A$6=$E$2;$B$2:$B$6;"");LIGNE(A1))
Formula in G2:
=INDEX($C$2:$C$6,MATCH(F2,$B$2:$B$6,0))
Or in French
=INDEX($C$2:$C$6;EQUIV(F2;$B$2:$B$6;0))
Note: The first formula is an array formula and need to be confirmed through CtrlShiftEnter.
Drag them both down and include an IFERROR if you drag these formula's down and you don't want to see errors once there are no more hits.

Vlookup doesnt read mixture of Alphabet and Numbers eg: 1T902462K01

i have a table as below and i wanted to compare result using Vlookup.
A | B | C
-------------------------
1 | ID | Name | Lot
-------------------------
2 | 70100 | Krenn | VF849062
-------------------------
3 | 70101 | Georg | VE803354
-------------------------
4 | 70102 | Mohd | VE803354
However =VLOOKUP(C2,A1:C4,1,FALSE) will result #N/A
Any advise?
Regards,
Zaiem
Try the Index/Match suggested in the comments. It goes like this:
=index(A1:A4,match(F1,C1:C4,0))
in words: find the value of F1 in the range C1 to C4 and return the value from column A for the same row.
Your Vlookup formula references C2, which does not make sense if column C is the column where you perform the lookup.

excel return the value of a cell based on two other values

What I'm trying to do is a little complex but I think it's doable in Excel.
I have two worksheets in a workbook on sheet one I have this...
| Code1 | Code2 | Code3 | Code4 |
| BA1 | xxxxx | xxxxx | |
| BA2 | xxxxx | xxxxx | |
| BA3 | xxxxx | xxxxx | |
And on the second sheet...
| CodeA | CodeB | CodeC | CodeD |
| BA1 | 1 | date | text |
| BA3 | 1 | date | text |
| BA1 | 2 | date | text |
| BA2 | 1 | date | text |
| BA1 | 3 | date | text |
| BA3 | 2 | date | text |
| BA2 | 2 | date | text |
What I want to do is lookup Code1 on sheet one and find it in the second sheet in CodeA then find the highest CodeB for CodeA and then concatenate CodeC and CodeD and place them on Sheet one in Code4.
I hope that makes sense, Thanks for any advice.
I think I understand. Does this look correct?
Sorry for the swedish formulas but it's an array formula that you add with CTRL+SHIFT+ENTER.
The formula in english is:
{=MAX(IF(Data=A2,CodeB;-1))}
And the named range Data is Column H and I, and CodeB is Column I.
If it does not find the value it returns -1
Sorry noticed now that I only did half of the job.
Make another named range called Table that spans column I to K (Code B -> Code D).
And in column code3 add this formula:
=Vlookup(B2,Table,2,false)
And in code4:
=Vlookup(B2,Table,3,false)
And you should get:
This should find the results you are looking for.
This is an array formula so you will need to press CTRL+SHIFT+ENTER once you have entered it into the formula bar, this will have to done for every formula you add to the column.
As it is an array formula I have only written it to reference rows 1 to 18, you will need to update all references to include you last row.
Columns titled CODE1(to 4) are on the first sheet (Sheet 1)
Columns titled CODEA(to D) are on the Second sheet (Sheet 2)
=CONCATENATE(VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!C1:C18 ),2,0)," ",VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!D1:D18 ),2,0))
If you do not require a space between the dates, just remove " ", from the middle of the formula.

Excel Formula Optimisation

I am no excel expert and after some research have come up with this formula to look at two sets of the same data from different times. It then displays new entries that are in the latest list of data but not in the old list.
This is my formula:
{=IF(ROWS(L$4:L8)<=(SUMPRODUCT(--ISNA(MATCH($E$1:$E$2500,List1!$E$1:$E$2500,0)))),
INDEX(E$1:E$2500,
SMALL(IF(ISNA(MATCH($E$1:$E$2500&$F$1:$F$2500,List1!$E$1:$E$2500&List1!$F$1:$F$2500,0)),
ROW($F$1:$F$2500)-ROW($F$1)+1),ROWS(L$4:L8))),"")}
Are there any optimisation techniques I could employ to speed up the calculation?
As requested
Some example data(link to a spreadsheet):
https://docs.google.com/file/d/0B186C84TADzrMlpmelJoRHN2TVU/edit?usp=sharing
On this scaled down version its more efficent but on my actual sheet with a lot more data it is slowed.
Well, I was playing around a bit and I think that this works the same, and without the first IF statement:
=IFERROR(INDEX(A$1:A$2500,SMALL(IF(ISNA(MATCH($A$1:$A$2500&$B$1:$B$2500,List1!$A$1:$A$2500&List1!$B$1:$B$2500,0)),ROW($B$1:$B$2500)-ROW($B$1)+1),ROWS(F$2:F2))),"")
That part in your sample data:
ROWS(F$2:F2)<=(SUMPRODUCT(--ISNA(MATCH($A$1:$A$2500,List1!$A$1:$A$2500,0))))
As I understood it, it only sees to it that the row number in which the formula is entered is lower than the number of 'new' items, but it doesn't serve any purpose because when you drag the formula more than required, you still get errors instead of the expected blank. So I thought it could be removed altogether (after trying to substitute it with COUNTA() instead) and use an IFERROR() on the part directly fetching the details.
EDIT: Scratched that out. See barry houdini's comment for the importance of those parts.
Next, you had this:
ROW($B$1:$B$2500)-ROW($B$1)+1
-ROW($B$1)+1 always returns 0, so I didn't find any use to it and removed it altogether.
It's still quite long and takes some time I guess, but I believe it should be faster than previously by a notch :)
A relatively fast solution is to add a multi-cell array formula in a column alongside List 2
{=MATCH($A$1:$A$16,List1!$A$1:$A$11,0)}
and filter the resultant output for #N/A.
(Or see Compare.Lists vs VLOOKUP for my commercial solution)
Array formula is slow. When you have thousands of array formula, it will make the speed very slow. Thus the key will be to avoid any array formula.
The following will be my way to achieve it, using only simple formula. It should be fast enough if you only have 2500 rows.
Column F and H are "Keys", created by concatenating your 2 columns (E and F in your original formula)
Assuming the first line of data is on row 3.
Data:
| A | B | | D | E | F | | H |
| index | final value | | ID | exist in Old? | Key (New) | | Key (Old) |
--------------------------------------------------------------------------------
| 1 | XXX-33 | | 0 | 3 | OOD-06 | | OOC-01 |
| 2 | ZZZ-66 | | 0 | 1 | OOC-01 | | OOC-02 |
| 3 | ZZZ-77 | | 1 | N/A | XXX-33 | | OOD-06 |
| 4 | | | 1 | 4 | OOE-01 | | OOE-01 |
| 5 | | | 1 | 2 | OOC-02 | | OOF-03 |
| 6 | | | 2 | N/A | ZZZ-66 | | |
| 7 | | | 3 | N/A | ZZZ-77 | | |
Column E "exist in Old?": test if the new key (Column F) exists in the old list (Column H)
=MATCH(F3, $H$3:$H$2500, 0)
Column D "ID": to increment by one whenever a new item is found
=IF(ISNA(E3), 1, 0)+IF(ISNUMBER(D2), D2, 0)
the 2nd part of ISNUMBER is just for the first row, where just using D2 can cause an error
Column A "index": just a plain series starting from 1 (until the length of new list Column F)
Column B "final value": to find the new key by matching column A to Column D.
=IF(A3>MAX($D$3:$D$2500), "", INDEX($F$3:$F$2500, MATCH(A3, $D$3:$D$2500, 0))
This column B will be the list you want.
If it is still too slow, there exists some dirty tricks to speed up the calculation, e.g. by utilizing a sorted list with MATCH( , , 1) instead of MATCH( , , 0).

Resources