Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

How to filter only 5 & 6 digits value in a column

vpalani08
6 - Meteoroid

I have a column with 5 digits, 6 digits, 10 digits and 9 digits value.
I only need to filter the value with 5 & 6 digits.
I tried RegEx ribbon but if I say 5,6 in a column it trims of other values as well. I don't need that to happen.

Any help will be very helpful....

Thanks,

6 REPLIES 6
mpennington
11 - Bolide

I'm not sure I follow exactly, but if you are wanting to keep only strings that are 5 or 6 digits long, you can filter with this formula:

REGEX_Match(ToString([Strings]), '^\d{5,6}$')

This result for TRUE node:

True.png

This for FALSE node:

False.png

Luke_C
17 - Castor
17 - Castor

Hi @vpalani08 

 

Here's a non-regex approach. Depending on if your data is a string or numeric the 'tostring' piece may not be necessary.

 

Length(tostring([Field1])) in (5,6)

 

Luke_C_0-1623781836876.png

 

vpalani08
6 - Meteoroid

Thanks that works perfectly.

RRaoDannayak
7 - Meteor

Thank you for this solution I like it, however lets say if i want to filter the data that has 1,2,3,4 numbers in it like 

1

11

111

1111 

I tried using the formula and by adding additional required values but it didn't work as its only working for 2 values 

REGEX_Match(ToString([ACCT-NBR]), '^\d{1,2,3,4}$')

 

Did i do anything wrong in the formula ?? 

 

Luke_C
17 - Castor
17 - Castor

Hi @RRaoDannayak 

 

Change it to the below and it should work

 

REGEX_Match(ToString([ACCT-NBR]), '^\d{1,4}$')

RRaoDannayak
7 - Meteor

Hi @Luke_C  Thanks for your reply, yup works like a champ :)

Labels
Top Solution Authors