We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

How to include leading 0 in a Length filter

svargas01
6 - Meteoroid

Hi all!

I am trying to filter a dataset to include only numbers that are 9 digits in length - here is my formula:

 

length(tostring([column1]))=9

 

the issue is that if the number has a leading 0, it does not see that as 9 digits. Is there a different way to write this to include the leading 0 in the count?

 

Thanks in advance!

4 REPLIES 4
aatalai
15 - Aurora

convert it to string first/import it as a string

oyes2704
8 - Asteroid

Hi @svargas01 , 

You are almost there! I would use Regex replace to strip leading 0s:

 

length(REGEX_Replace(tostring([column1]),'^0+',''))

 

Hope it works,

Oly

kamal03
9 - Comet

hi @svargas01 

 

If I am not wrong you need to count the numbers excluding 0 in front. then you can achieve this by using the below formula in the formula tool and then filtering it with the filter tool.

 

Length(TrimLeft([Column1], '0'))

 

 

Let me know if you have any other requirement , thanks

svargas01
6 - Meteoroid

thank you all! the regex fixed it! 

Labels
Top Solution Authors