ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
GELÖST

Contains function - number of hits

janez_007
Meteor

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?

 

4 ANTWORTEN 4
nerces
Asteroid

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.

janez_007
Meteor

ok, understood, thank you for the reply.

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

 

janez_007
Meteor

REGEX_CountMatches works perfectly, thank you for the suggestion.

Beschriftungen
Top-Lösungs-Autoren