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.
解決済み

How to include leading 0 in a Length filter

svargas01
メテオロイド

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件の返信4
aatalai
オーロラ

convert it to string first/import it as a string

oyes2704
アステロイド

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
コメット

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
メテオロイド

thank you all! the regex fixed it! 

ラベル
トップのソリューション投稿者