Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Repeat page header in front of each record

oracleoftemple
9 - Comet

I imported a PDF and separated each row into its own record.  The field is called "txt".  There's some info in the header of each page that I need to keep and have repeated in each record.  It looks like this "PERIODMM-YY".  I'm trying to repeat the MM-YY in front of each record, until it changes to the next period - then I want to repeat THAT period in front of each record.  I'm trying to use a Multi-Row Formula tool, add a new field and use the following expression:

 

IF RegEx_Match([Row-1:txt],'PERIOD(\d\d-\d\d)')
THEN RegEx_Match([Row-1:txt],'PERIOD(\d\d-\d\d)')
ELSE [Row-1:New Field]
ENDIF

 

So basically, if the pattern is found in the prior row, I want to capture the subgroup \d\d-\d\d and put it in a New Field.  If it doesn't match the pattern, I want to output the value in New Field from the previous row.

 

I'm not getting an error, but the New Field is not returning any data.

3 REPLIES 3
danrh
13 - Pulsar

I think the issue might be in the second row. Try the following instead:

 

IF RegEx_Match([Row-1:txt],'PERIOD(\d\d-\d\d)')
THEN RegEx_Replace([Row-1:txt],'PERIOD(\d\d-\d\d)','$1')
ELSE [Row-1:New Field]
ENDIF

 

RegEx_Match returns a boolean (true/false), which if you put into a text field it will return a -1 or a 0. Use RegEx_Replace to pull out a single piece of information from a string.

 

Does that fix the issue? If not, can you post some sample data?

oracleoftemple
9 - Comet

I'm afraid it's still blank.  See attached for example.  I just need 01-17 repeated in front of each record until it changes to another period, e.g., 02-17.  Those two rows at the bottom are my records.  I don't need any of the other info.

oracleoftemple
9 - Comet

 Ok I figured it out.  I used a RegEx tool to Tokenize the MM-YY using the expression: PERIOD(\d\d-\d\d).  I then used a Multi-Row Formula tool to update that new field using the expression: IF IsEmpty([1]) THEN [Row-1:1] ELSE [1]
ENDIF.

Labels
Top Solution Authors