Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Regex Match Formula for Filter

Dave_McClintock
6 - Meteoroid

I have many spreadsheets that each have multiple tabs that I am working on a macro to import. The issue I am running into is that I don't want to import all the tabs that are included. There is no real method how the sheets were named, due to multiple people creating the names. The general rule is that I want to filter the sheets to only those that contain a specific date of some kind ideally. Below are some of the variations that I have seen that I would want to include, as well as some that I would not want to include.

 

I feel like using a REGEX_MATCH formula would be my best bet, but I have not been able to think of what would work for this situation. It doesn't have to be 100% as far as excluding, but I need to make sure it includes anything with a date specific date regardless of format or additional info in the sheet name like below. Any assistance with this would be greatly appreciated. Thanks. 

 

Include:
Prod Hours 2-04-19
FLDC Prod 4-24-19
12-31
Feb 13
8-28-
Sep 30
April 23
Apr 23
4-24
Apr 24
1-01
1-1
1.1
1.10
01-1
1-01

 

Don't Include:
WE 3.9- 4.6 Texas
g
Hours
hrs
IADC Hourly Labor Report
MON
N1
TUE
TXDC Hourly Labor Report
Sheet3
Sheet4
Sheet22
OKDC Hourly Labor Report
FLDC Hourly Labor Report
f
FLDC Hrs
Data Entry
Directions
e
f
b
c
d
ARDC Hourly Labor Report
a
1111
0
00
1
01

2 REPLIES 2
jdunkerley79
ACE Emeritus
ACE Emeritus

I'd suggest:

 

REGEX_Match([Field1], ".*\d{1,2}[.-]\d{1,2}.*")
OR
REGEX_Match([Field1], 
            ".*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\S* \d{1,2}.*")

 

 

It's not perfect and will match 'WE 3.9- 4.6 Texas' but otherwise think works

 

A slight tuning is:

REGEX_CountMatches([Field1], "\d{1,2}[.-]\d{1,2}") == 1
OR
REGEX_Match([Field1], 
            ".*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\S* \d{1,2}.*")

 

Have attached a sample

Dave_McClintock
6 - Meteoroid

@jdunkerley79  that is perfect and makes total sense now that I am looking at it and broke it down. Thanks for the help! 

Labels