Partial match lookup

iyeung26

New Member
Joined
Aug 28, 2017
Messages
3
Hi all - first post, would appreciate some help. I have an extract from SharePoint on Excel and I want to do a lookup against my Excel mapping table.

The table I have in the spreadsheet is the "List from SharePoint" where I have a string with lots of # and ;s, I want to use that string and lookup against a table and count how many vegetables/fruit there are.

I would like the outcome of the lookup to be the numbers in orange below, is this feasible? I prefer to use the mapping table as my list of vegetables & fruit are quite long :) Thanks.

List from SharePointLookup output: FruitLookup output: Vegetable
;#Apple;#Pear;#Carrot;#21
;#Apple;#Pear;#Tomatoes;#Carrot;#22
Mapping tableType
AppleFruit
PearFruit
CarrotVegetable
TomatoesVegetable

<tbody>
</tbody><colgroup><col><col span="2"></colgroup>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Welcome to the MrExcel board!

Firstly a newbie tip: Even if you are in a hurry, don't bump your post so quickly. At the top of the forum is a "Zero Reply Posts" and many of the experienced helpers go there first to look for questions that need answering. As soon as you replied to your own thread, it no longer appeared in that list, so you immediately tend to get less 'lookers' & potential helpers. If you haven't done so yet, I suggest that you have a good look at the Forum Rules and the Forum Use Guidelines.

Now for your problem. Does this do what you want? This is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied across and down.

Excel Workbook
ABC
1List from SharePointFruitVegetable
2;#Apple;#Pear;#Carrot;#21
3;#Apple;#Pear;#Tomatoes;#Carrot;#22
4
5
6
7Mapping tableType
8AppleFruit
9PearFruit
10CarrotVegetable
11TomatoesVegetable
Count
 
Last edited:
Upvote 0
List from SharePointFruitVegetable
;#Apple;#Pear;#Carrot;#21
;#Apple;#Pear;#Tomatoes;#Carrot;#22
Mapping tableType
AppleFruit
PearFruit
CarrotVegetable
TomatoesVegetable

<tbody>
</tbody>

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

=SUM(IF(ISNUMBER(SEARCH($A$6:$A$9,$A2)),IF($B$6:$B$9=B$1,1)))
 
Upvote 0
In B2 control+shift+enter, not just enter, copy across, and down:

=SUM(IF(ISNUMBER(SEARCH($A$6:$A$9,$A2)),IF($B$6:$B$9=B$1,1)))
Hi Aladin

Note that is not robust against fruits and vegetables that share a common word. For example, the mapping table already has the Fruit "Apple", but if it also included the Vegetable "Ground Apple" (from Peru) then your formula would give an incorrect count for fruit for the string ";#Ground Apple;#Pear;#Carrot;#"
 
Last edited:
Upvote 0
Hi Aladin

Note that is not robust against fruits and vegetables that share a common word. For example, the mapping table already has the Fruit "Apple", but if it also included the Vegetable "Ground Apple" (from Peru) then your formula would give an incorrect count for fruit for the string ";#Ground Apple;#Pear;#Carrot;#"

Thanks. That's easily corrected for...

=SUM(IF(ISNUMBER(SEARCH(";#"&$A$6:$A$9&";#",SUBSTITUTE($A2," ",""))),IF($B$6:$B$9=B$1,1)))
 
Upvote 0
That's easily corrected for...

=SUM(IF(ISNUMBER(SEARCH(";#"&$A$6:$A$9&";#",SUBSTITUTE($A2," ",""))),IF($B$6:$B$9=B$1,1)))
That still fails for the example I gave as the SUBSTITUTE then naturally fails to match GroundApple with Ground Apple.
I think with your approach, the following should suffice

{=SUM(IF(ISNUMBER(SEARCH("#"&$A$6:$A$9&";",$A2)),IF($B$6:$B$9=B$1,1)))}
 
Upvote 0
That still fails for the example I gave as the SUBSTITUTE then naturally fails to match GroundApple with Ground Apple.
I think with your approach, the following should suffice

{=SUM(IF(ISNUMBER(SEARCH("#"&$A$6:$A$9&";",$A2)),IF($B$6:$B$9=B$1,1)))}

Or...

{=SUM(IF(ISNUMBER(SEARCH(";#"&SUBSTITUTE($A$6:$A$10," ","")&";#",SUBSTITUTE($A2," ",""))),IF($B$6:$B$10=B$1,1)))}

The idea is clear and simple, although never exhaustively safe for any possible case.
 
Upvote 0

Forum statistics

Threads
1,221,417
Messages
6,159,789
Members
451,589
Latest member
Harold14

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