Hi everyone,
need support using the Contains function. I am doing a simple word search and would like to get the number of hits.
Example text:
A brown cat is in the garden for brown cats.
Keyword:
brown cat
The contains function returns '-1' even though there are two hits in the sentence. Any suggestions?
Solved! Go to Solution.
That's because the contains functions returns a TRUE or FALSE value. It does not return a count of the number of instances for your keyword.
ok, understood, thank you for the reply.
Hi Janez,
You can find the solution for this by using the help documentation.
https://help.alteryx.com/current/Reference/Functions.htm
The contains formula returns a boolean value based on whether the text is contained in the field.
The function you want is probably Regex_CountMatches and looks like this.
REGEX_CountMatches([Sample_text], "brown cat")
REGEX_CountMatches works perfectly, thank you for the suggestion.