Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Delete/Filter Rows in Which a Cell Doesn't Meet a Specific Format

shaheer
8 - Asteroid

I have a set of data that looks like the following:

 

Input:

Project NameOpen?
1000000423Yes
2021005821No
2022-MF-TM-328Yes

 

I wish to remove all rows in which the Project is not a 10 digit value.

 

Output:

Project NameOpen?
1000000423Yes
2021005821No

 

I have tried the following using the filer tool, but it did not work. I have tried a few different methods with no success.

 

shaheer_0-1669824603672.png

 

Next, after filtering the data, I want to add two letters PR infront of the project name values to make it look like the following:

 

Project NameOpen?
PR1000000423Yes
PR2021005821No

 

Follow up question, where can I practice regular expression problems online? I want to get better at them. Thank you.

 

5 REPLIES 5
Luke_C
17 - Castor
17 - Castor

Hi @shaheer 

 

The basic filter does not support regex. 

 

You can do a custom filter: Length([Project Name]) != 10

DataNath
17 - Castor
17 - Castor

Hey @shaheer the first step would be to perform a filter based on a regex_match() of 10 digits:

 

REGEX_Match([Project Name], '\d{10}')

 

DataNath_0-1669824962913.png

 

To add 'PR' to the front of these values, that's a simple addition expression:

 

DataNath_1-1669824984010.png

 

To learn/practice RegEx, I'd recommend watching the parsing Interactive lessons - https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Parsing%20...

There's also a great guide here that @MeganBowers uploaded yesterday - https://community.alteryx.com/t5/Alteryx-Designer-Discussions/New-Resource-Guide-for-RegEx-Text-Pars...

For testing expressions before using them, sites like https://regex101.com/ are brilliant.

shaheer
8 - Asteroid

But if I do length != 10, it would include non-digit characters. I only want the 10 digit numbers.

Luke_C
17 - Castor
17 - Castor

Hi @shaheer Understood, @DataNath has you covered!

shaheer
8 - Asteroid

Awesome, both of these work perfectly. Thank you so much and thanks for the links as well!

Labels
Top Solution Authors