categorize text strings by keywords and their synonyms with textjoin, if, countif

Qcarper

New Member
Joined
Mar 10, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,


I'm trying to automatically categorize a large amount of products by finding keywords in the product descriptions. Using a textjoin, if, count if fucntion works perfectly because if mutiple keywords match, it indexes all of them.
But these products come from a range of different suppliers often using slightly different words for the same product, that's why for most keywords i wrote some synonyms behind them, but i dont want to index all of these synonyms if they match, just the first keyword.


=TEXTJOIN(", ",TRUE,IF(COUNTIF($B$9:$B$12,"*"&$F$9:$F$11&"*"),$F$9:$I$11,""))

This table has thousands of products and more products are added regularly so a dynamic solution for this would be perfect.

could someone help me with this?
 

Attachments

  • screenshot textjoin problem.jpg
    screenshot textjoin problem.jpg
    165.2 KB · Views: 13

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi & welcome to MrExcel.
Can you post some sample data, rather than an image.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hi & welcome to MrExcel.
Can you post some sample data, rather than an image.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Table - Data insert.xlsx
BCDEFGHI
5=TEXTJOIN(", ",TRUE,IF(COUNTIF($B$9:$B$12,"*"&$F$9:$F$11&"*"),$F$9:$I$11,""))
6now
7
8Item descriptioncategoryKeyword list
9This item has a synonym a1 and keyword bSynonym a1, 0, keyword bkeyword aSynonym a1Synonym a2
10Red Synonym b20, Synonym b2keyword bSynonym b1Synonym b2Synonym b3
11Blue and white synonym c1 with a square synonym b30, Synonym b3, Synonym c1keyword cSynonym c1Synonym c2Synonym c3
12Item without a know keyword0
13
14
15my whish
16
17Item descriptioncategoryKeyword list
18This item has a synonym a1 and keyword bKeyword a, keyword bkeyword aSynonym a1Synonym a2Synonym a3
19Red Synonym b2Keyword bkeyword bSynonym b1Synonym b2Synonym b3
20Blue and white synonym c1 with a square synonym b3Keyword c, keyword bkeyword cSynonym c1Synonym c2Synonym c3
21Item without a know keyword
Sheet1
Cell Formulas
RangeFormula
C9:C12C9=TEXTJOIN(", ",TRUE,IF(COUNTIF($B9,"*"&$F$9:$I$11&"*"),$F$9:$I$11,""))
 
Upvote 0
Thanks for that.
How about
+Fluff 1.xlsm
BCDEFGHI
8Item descriptioncategoryKeyword list
9This item has a synonym a1 and keyword bkeyword a, keyword bkeyword aSynonym a1Synonym a2Synonym a3
10Red Synonym b2 keyword bkeyword bkeyword bSynonym b1Synonym b2Synonym b3
11Blue and white synonym c1 with a square synonym b3keyword b, keyword ckeyword cSynonym c1Synonym c2Synonym c3
12Item without a know keyword 
13
Lists
Cell Formulas
RangeFormula
C9:C12C9=TEXTJOIN(", ",TRUE,IF(MMULT(--(ISNUMBER(SEARCH($F$9:$I$11,B9))),SEQUENCE(COLUMNS($F$9:$I$9),,,0))>0,$F$9:$F$11,""))
 
Upvote 0
Thank you very much for your reply.

But something seems to be wrong, it definitely works in the XL2BB example you sent. But when I paste it to my own worksheet this happens:

1646926452721.png


even though the formula is the same:
1646926480020.png


For the actual data model i need this for it means this XD

1646926536725.png


it goes on for a little while...

Do you perhaps know what could cause this?
 
Upvote 0
It's because you have a blank cell in the F9:I11, try it like this instead
Excel Formula:
=TEXTJOIN(", ",TRUE,IF(MMULT(($F$9:$I$11<>"")*(ISNUMBER(SEARCH($F$9:$I$11,B9))),SEQUENCE(COLUMNS($F$9:$I$9),,,0))>0,$F$9:$F$11,""))
 
Upvote 0
Solution
It's because you have a blank cell in the F9:I11, try it like this instead
Excel Formula:
=TEXTJOIN(", ",TRUE,IF(MMULT(($F$9:$I$11<>"")*(ISNUMBER(SEARCH($F$9:$I$11,B9))),SEQUENCE(COLUMNS($F$9:$I$9),,,0))>0,$F$9:$F$11,""))
Oh my god u absolut madlad!!
thank you so much, this is going to save me so many hours!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,019
Members
449,060
Latest member
LinusJE

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