Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Contains vs. FindString

onicholson
7 - Meteor

Is there a benefit to using FindString != -1 vs. Contains as an if, then qualifier? I know the benefit of using contains is that it gives the case insensitive option which you can't do with findstring without uppercase([field]) or lowercase([field]), but is there a downside to using this over findstring?

7 REPLIES 7
MarqueeCrew
20 - Arcturus
20 - Arcturus
👍 question!

If the context of the string is important, the findstring function let's you know where it was found. It can be very helpful if you are going to perform other string functions.

The regex_match function will give you super powers. Using it, you can be case sensitive or insensitive and add patterns as well counts of matches (regex_countmatches) to see if it contains many targets.

I hope that this helps you.

Cheers,

Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
NicoleJohnson
ACE Emeritus
ACE Emeritus
FindString will actually tell you the position of the field you're looking for, whereas Contains just tells you whether or not it finds the string as a True/False answer.

So if you only need to know whether or not a string contains something else (i.e. "Green Apples" contains the word "Apple" but "Bartlett Pears" does not), then I would use Contains, especially because it has the option of making it case sensitive...

But if you need to know at which character "Apple" starts so that you can parse out anything in front of it, then you might want to use FindString.

Contains("Green Apples","Apples") = -1 (<-- Which in this case means True)
FindString("Green Apples","Apples") = 6

Hope that helps!

NJ
Mancunian
8 - Asteroid

I have a coloumn with all months and years since 2011, but I just need to extract the years 2016 and 2017. How can I specify these 2 years in a single FindString Formula.

 

The data is  april, 2016, May, 2013, January 2017

 

I have been trying this but to no avail.

 

FindString([DateTime_Out],"2016"&"2017")>-1

 

 

onicholson
7 - Meteor

You just need to use two FindString expressions - you can put them in the same formula with "or" in between:

 

FindString([DateTime_Out],"2016")>-1 or FindString([DateTime_Out],"2017")>-1

 

 

Kim_Donner
6 - Meteoroid

I somehow have to pull versions from a specified lookup table which hold values like this:

 

Full Version:

9.0.22

9.0.1

8.5.41.B.RELEASE 

 

Install paths are like this:

Installation Path
/OPT/APPS/TCSERVER3216/TOMCAT-8.5.41.B.RELEASE
/OPT/APPS/TCSERVER3216/TOMCAT-8.5.41.B.RELEASE
/TMP/TEZ/TEZ-0.8/TOMCAT/APACHE-TOMCAT-9.0.1
/APPS/APACHE-TOMCAT-9.0.22_MSGAA_C3_W2_SV
/APPS/APACHE-TOMCAT-9.0.22_PCS_SV1

 

 

/APPS/APACHE-TOMCAT-9.0.22_MS_SV1
/APPS/APACHE-TOMCAT-9.0.22_CC_C3_SV2
/APPS/APACHE-TOMCAT-9.0.22_CC_SV1
/APPS/APACHE-TOMCAT-9.0.22_IRT_SV1
/APPS/APACHE-TOMCAT-9.0.22_WINS_SV1
/FSTAPPS/FSTOHS/TOMCAT
/APP/ST/SYNINSTALL/SYNPATCH/026/COMPONENT/TOMCAT
/OPT/APPS/TCSERVER3216/TOMCAT-8.5.41.B.RELEASE
/APP/ST/SYNINSTALL/SYNPATCH/017/COMPONENT/TOMCAT
/APP/ST/SYNINSTALL/SYNPATCH/017/COMPONENT/TOMCAT
D:\APPS\TOMCAT\CURRENT
D:\APPS\TOMCAT\BOTOMCAT\

 

4 days to no avail please any help would be super appreciated. 

lmorrell
11 - Bolide

Hi @Kim_Donner 

 

Solution is attached. 

 

Snag_6d1a3174.png

 

 

Although it's not in line with the original question, this is a great example to leverage RegEx. If only full version numbers are required then using the below in a RegEx tool with the Output method set to Parse will pull out the examples.

(\d+\.\d+\..*)

 

If the full path contains a non-version number (eg. TOMCAT, BOTOMCAT) and this is required - then by first trimming the field of '\' and '/' and then using the below RegEx replace to isolate the final component of the full path, these can also be obtained. 

trim([Field1], '\/')
if isnull([Full Version]) then REGEX_Replace([Field1], '.*\/|.*\\', '')
else [Full Version]
endif

 

Hope this helps!

Kim_Donner
6 - Meteoroid

Awesome I started with RegEx and just couldn't get there. I think I see why given your response. I will test now. Thank you very much. 

Labels
Top Solution Authors