Free Trial

Alteryx Designer Desktop Discussions

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

Custom Formula to Find a Specific Character

lwolfram
5 - Atom

I have an account field that is always 7 digits long.  I need to find where the 5th digit is a 7.  The number 7 could be anywhere in the account field, but I don't want to capture those.  So the StartsWith, EndsWith and RegEx won't work for me.  Does anyone have any other suggestions for how to locate these accounts.

 

So in the 4 examples below, I would only want to return the first 3 accounts.

 

4300701
4300755
4040788
4470000

 

Thank you!

 

Leigh

 

4 REPLIES 4
CharlieS
17 - Castor
17 - Castor

Hi @lwolfram 

 

Without RegEx, this expression could be used in a Formula tool:

 

IF Right(left(tostring([Account]),5),1)=='7' THEN 'true' ELSE 'false' ENDIF

 

 

Thableaus
17 - Castor
17 - Castor

Hi @lwolfram 

 

You could use this formula:

 

IF Substring(ToString([Field1]),4,1) = "7" THEN "Yes" ELSE "No" ENDIF

 

Substring function can get a start and a length to find strings.

 

Cheers,

danilang
19 - Altair
19 - Altair

Hi @lwolfram 

 

Just cause I've been trying to use the Regex hammer on everything that looks like a nail recently and also it's fun to do things differently from @Thableaus and @CharlieS (But don't tell them that

 

REGEX_Match(tostring([Field1]), "\d{4}7\d{2}")

This matches a "7" as the 5 character

 

regex7.png

 

Dan

lwolfram
5 - Atom

Thank you all!  Those are all great Solutions!

Labels
Top Solution Authors