Fuzzy match on google sheets

老子叫甜甜 提交于 2019-12-07 17:38:34

问题


I'm trying to fuzzy match two columns in google sheets, i've tried numerous formulas but I think it's going to come down to a script to help out.

I have a column with product ID's e.g.

  • E20067

and then I have another sheet with another column which has image url's relating to this product code such as

  • http://wholesale.test.com/product/E20067/web_images/E20067.jpg
  • http://wholesale.test.com/product/E20067/high_res/E20067.jpg
  • http://wholesale.test.com/product/E20067/high_res/E20067-2.jpg

What I'm wanting to do is "fuzzy" match both of these columns for their product ID, and then create a new column for each match. So it would have the product ID then on the same row in multiple columns each product image URL - like the image below:

Is there a way to do this in google sheets using a script or a formula?


回答1:


Old thread but, in case you find yourself here, search for my Google Sheets add-on called Flookup. It should do exactly what you want.

For this case, you can use this function:

Flookup (lookupValue, tableArray, lookupCol, indexNum, threshold, [rank])

The parameter details are:

  1. lookupValue: the value you're looking up
  2. tableArray: the table you want to search
  3. lookupCol: the column you want to search
  4. indexNum: the column you want data to be returned from
  5. threshold: the percentage similarity below which data shouldn't be returned
  6. rank: the nth best match (i.e. if the first one isn't to your liking)

*You can find out more at the official website (examples and such).

Please note that, whereas the OP appears to want the whole list of possible matches, Flookup will only return one result at a time.




回答2:


In Google sheets there are a few powerful 'regex' formulas.

Suppose, you have ID list in column A, and URL list in column B

Then use formula:

=REGEXEXTRACT(B1,JOIN("|",$A$1:$A$3))

It will match one of ID's. Drag the formula down to see the result as in picture above.

See more info here




回答3:


Try the following. I am assuming the product codes are in Sheet1 and the URLs are in Sheet2. Both in column A:

=iferror(transpose(FILTER(Sheet2!$A$2:$A,Search("*"& A2 &"*",Sheet2!$A$2:$A))))

Copy down.

If you want to show the image instead of the url try:

=arrayformula(image(iferror(transpose(FILTER(Sheet2!$A$2:$A,Search("*"& A2 &"*",Sheet2!$A$2:$A))))))


来源:https://stackoverflow.com/questions/40468119/fuzzy-match-on-google-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!