community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
SOLVED

Contains function - number of hits

Meteoroid

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?

 

Meteor

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.

Meteoroid

ok, understood, thank you for the reply.

Highlighted
Meteor

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")

 

Meteoroid

REGEX_CountMatches works perfectly, thank you for the suggestion.

Labels