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

Alteryx Designer Desktop Discussions

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

Rookie questions - Parsing numbers

calloni
9 - Comet

Hello, downloaded Alteryx today and I am having lots of fun with it.

 

I have a very punctual question. How can I create a workflow to parse a number to detect if it is a palindrome (for example 12321 or 1987891)

 

Thanks in advance!
Rodrigo

 

 

11 REPLIES 11
NicoleJohnson
ACE Emeritus
ACE Emeritus
You can create a new field in your formula tool called ReverseNumber (or whatever you want to call it) - the trick is to name the new formula something else using the “+ Add New Field” option rather than selecting the existing field from the drop down for formula name, so that you don’t overwrite whatever is in the original field. Then in the Filter tool, the formula you can use in the custom formula section below would be something like [OriginalNumber] = [ReverseNumber]. For those records that are true for that statement, they will show up in the True output branch. Anything that doesn’t match/isn’t a palindrome will show up in the False branch.

If the formula gives you an error, try adding either ToNumber() or ToString() wrapped around each of the field names, like ToNumber([ReverseNumber]) if the OriginalNumber is a number type, not a string.

NJ
NicoleJohnson
ACE Emeritus
ACE Emeritus
Try the ReverseString formula! (You might need to wrap a ToString formula around your original numbers as well depending on the field type). You can then use a filter to test if the Reverse version is equal to the original... let us know if that works! And awesome to hear you are having fun with Alteryx!!

Cheers,
NJ
calloni
9 - Comet

OMG so many nice features on Alteryx! Thanks Nicole.

 

The first step worked and I got the reversed numbers. I am looking at the Filter option but don't find how to test it.

 

Should I create a new file out with the reversed numbers and then blend the original to it and compare?

Thanks NJ!

calloni
9 - Comet

hahaha everything seems so obvious... thanks a bunch.

 

My original goal is to check if the fields are palindromes and add a column saying True on those that are, leaving those that aren't with nothing.

 

Thanks for great help!

NicoleJohnson
ACE Emeritus
ACE Emeritus
If you want True in a column you could also do the palindrome match testing with a formula, just set the field type to Bool. Your formula would be IIF([OriginalNumber]=[ReverseNumber],1,0). The results would then show true (1) or false (0) based on results. Hope that helps - there are always a few different ways to solve a problem with Alteryx!

Cheers,
NJ
calloni
9 - Comet

I think we are almost there thanks so much.

 

Now I see True on the Number column and the Number shows up in the ReverseNumber column.

 

How can I show True on the second column?

I kind of know most of these conditional formulas from Tableau but this seems so much more powerful :)

calloni
9 - Comet

Hey I got it! Thanks a lot Nicole!


I will never forget you my first Alteryx friend lol :)

NicoleJohnson
ACE Emeritus
ACE Emeritus

Awesome! No problem - I think you will quickly find you have many friends here on the Alteryx Community!! :) Good luck, have fun exploring!

 

NJ

MarqueeCrew
20 - Arcturus
20 - Arcturus

@calloni,

 

My friend @NicoleJohnson has given you some great advice.  Here's a treat for Halloween...

 

REGEX_Match(tostring([NUMBER_TO_TEST]), "^((.)(?1)\2|.?)$")

Guess what that does ....

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels