Quantcast
Channel: Data Preparation & Blending discussions
Viewing all articles
Browse latest Browse all 4999

Need help with CONTAINS function

$
0
0

I'm trying to see if customer search terms match a product name that was later clicked on. I'm using the contains function to see if the product name contains what the customer used as a search term.  For the most part it's working, but one weird thing I keep seeing is that if there is a space then the function isn't counting it as a match. 

 

For example: 

search #search termproduct name match
1nikenike air yes
2nike airnike air no

 

On search # 1 the product name 'nike air' contains the search term 'nike', so for my purposes that is a match. 

 

The problem is that on search #2 even though the search term and product name are exact, it's still saying that it isn't a match. I thought maybe case was an issue, so i accounted for that (the product name is always uppercase so I made the search term uppercase).  I also thought maybe leading trailing spaces were an issue, so I accounted for that (with trim).  But it's still not working.

 

I'm guessing there's a flaw in my code?

 

IF [TradeName] != NULL()
AND [searchterm] != ''
AND CONTAINS(TRIM([TradeName]),Uppercase(TRIM([searchterm])))
THEN 'Yes'
ELSEIF [TradeName] != NULL()
AND [searchterm] != ''
AND NOT CONTAINS(TRIM([TradeName]),Uppercase(TRIM([searchterm])))
THEN 'No'
ELSE Null()
ENDIF


Viewing all articles
Browse latest Browse all 4999

Trending Articles