Alteryx Designer Desktop Discussions

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

Dynamically add multiple New columns based on the data

SanthoshRam
5 - Atom

I am unable to find the solution, I have built 80% of the workflow but got stuck at this point, below is the sample data where I am unable to proceed to the desired result,

From below data,

NEWIDField_1
10 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00
21234567981010 XXX/XX
3132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
4XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
5CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
60 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00
71234567981010 XXX/XX
8132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
9XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
10CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
1134.11 XX12 X XXX XXXXXXXX
1212234.11 XX12 X XXX XXXXXXXX
130 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00
141234567981010 XXX/XX
15132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
16XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
17CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
180 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00
191234567981010 XXX/XX
20132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
21XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
22CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
2334.11 XX12 X XXX XXXXXXXX

 

Desired output required

NEWIDField_1NameDtNameRow_alldataAcNumCash&FT1Afees&FT2FT3FT4FT5
10 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00THOR10/14/2019D 10.00 10.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00  
21234567981010 XXX/XX         
3132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX         
4XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00         
5CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00         
60 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00IRONMAN10/23/2019D 5,00.00 5,00.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.0034.11 XX12 X XXX XXXXXXXX12234.11 XX12 X XXX XXXXXXXX
71234567981010 XXX/XX         
8132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX         
9XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00         
10CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00         
1134.11 XX12 X XXX XXXXXXXX         
1212234.11 XX12 X XXX XXXXXXXX         
130 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00THOR10/14/2019D 10.00 10.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00  
141234567981010 XXX/XX         
15132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX         
16XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00         
17CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00         
180 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00IRONMAN10/23/2019D 5,00.00 5,00.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.0034.11 XX12 X XXX XXXXXXXX 
191234567981010 XXX/XX         
20132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX         
21XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00         
22CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00         
2334.11 XX12 X XXX XXXXXXXX         

 

I need those FT columns to be added if there is any data below the "CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00 " , under each name 5 rows are fixed and after 5 rows it can have data (no limit) or it may not have.

 

Please help and my apologies if I have not explained it correctly.

 

Thank you!

9 REPLIES 9
echuong1
Alteryx Alumni (Retired)

I believe the attached workflow works for your purpose. Let me know if this is what you're looking for! 

 

It essentially uses conditional statements and multirow formulas to populate information. 

danilang
19 - Altair
19 - Altair

Hi @SanthoshRam 

 

Here's a dynamic solutions that handles any number of rows 

 

w.png

Start by building the superhero groups and then numbering the rows within each group.  Crosstab the rows to get the data in wide format.  Parse the Field_1 data using a Regex Parse tool to give you the Name, Dt and NameRow_Alldata columns.  Rename the remaining columns based on the values in Final Column Names.  Join to the Name rows and union in all the data.  After sorting, your output looks like this

 

r.png

 

It's not shown in this image, but FT4 and FT5 only have data where required

 

Dan

 

TonyA
Alteryx Alumni (Retired)

I put this together pretty quickly. It splits out the data into rows, including an arbitrary number of extra rows, but doesn't preserve the original data. If you need that I can tweak this to keep those columns.  I have an extra text input tool with the list of column names. That can be extended manually or you can extend the workflow to add more rows with column names.

SanthoshRam
5 - Atom

Thank you so much @echuong1 @danilang @TonyA for the solution.

 

@danilangI wanted exactly the solution what you have built and I can proceed with your solution to complete my workflow but after looking into @TonyA solution which is quick and the end result is exactly what I wanted and also I don't need to preserve the original data but right now I am into dilemma, first let me provide my sample data which is one step behind,

 

NEWIDField_1
1110/29/2019 00:35 XX CCCC XXX BNK, X.X. PAGE: 1
2BATCH #: 123456 BATCH DT: 10/26/2019 SOURCE: XXX/XX USERID: X123456
30 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00
41234567981010 XXX/XX
5132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
6XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
7CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
8110/29/2019 00:35 XX CCCC XXX BNK, X.X. PAGE: 1
9BATCH #: 456789 BATCH DT: 10/26/2019 SOURCE: XXX/XX USERID: X123456
100 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00
111234567981010 XXX/XX
12132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
13XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
14CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
1534.11 XX12 X XXX XXXXXXXX
1612234.11 XX12 X XXX XXXXXXXX
17110/29/2019 00:35 XX CCCC XXX BNK, X.X. PAGE: 2
18BATCH #: 987456 BATCH DT: 10/26/2019 SOURCE: XXX/XX USERID: X123456
190 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00
201234567981010 XXX/XX
21132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
22XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
23CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
240 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00
251234567981010 XXX/XX
26132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
27XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
28CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
2934.11 XX12 X XXX XXXXXXXX
3034.11 XX12 X XXX XXXXXXXX
310 THOR 10/14/2019 D 10.00 10.00 0.00 0.00 0.00
321234567981010 XXX/XX
33132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
34XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
35CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
360 IRONMAN 10/23/2019 D 5,00.00 5,00.00 0.00 0.00 0.00
371234567981010 XXX/XX
38132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXX
39XXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
40CLTR: 1XXXXXX/XXX: S/FEE: 0.00 0.00
4134.11 XX12 X XXX XXXXXXXX
4234.11 XX12 X XXX XXXXXXXX
4334.11 XX12 X XXX XXXXXXXX
4434.11 XX12 X XXX XXXXXXXX

 

Basically My end result will be like this,

Report DateBatch DateBatch NumberSourceUser IdNameDtNameRow_alldataAcNumCash&FT1Afees&FT2
10/29/201910/26/2019123456 XXX/XXX123456THOR10/14/2019D 10.00 10.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
10/29/201910/26/2019456789 XXX/XXX123456IRONMAN10/23/2019D 5,00.00 5,00.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
10/29/201910/26/2019987456 XXX/XXX123456THOR10/14/2019D 10.00 10.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
10/29/201910/26/2019987456 XXX/XXX123456IRONMAN10/23/2019D 5,00.00 5,00.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00
10/29/201910/26/2019987456 XXX/XXX123456IRONMAN10/23/2019D 5,00.00 5,00.00 0.00 0.00 0.001234567981010 XXX/XX132 03 XX - - X - 132564987 CAL: 10/27/2019 CASH: 10.00 FTCS: 10.00 X520 X GL: XXX XXXXXXXXXXX#1324657897 AGY: 2XXXXXX F/AGY: 2XXXXX A/FEE: 4.00 DUE 0.00

 

Please suggest how to proceed with this, I know I can take danilang solution by joining the report header and batch header. @TonyA do you have any suggestion or is it possible to tweak your workflow?

 

Thank you!

TonyA
Alteryx Alumni (Retired)

We could do this by adding another RowID for Batches and holding the batch columns as keys when we crosstab, I have some questions about the results. It appears that the new batch starts with one row for the Report data followed by a row that starts with the word BATCH (so we would increment the batch counter if [Row+1:Field_1] starts with "BATCH #:"). The records within the batch (first row starts with "0 ") appear to end with a row that starts with "CLTR:". The CLTR row and any row after that are not included in the output until we see the start of a new Batch or a new record. Is that correct? Also for batch 987456, why does the IRONMAN record appear twice?

 

I put something together assuming that we are keeping all the rows. If you wanted to drop the CLTR and addtional rows, I would tag them for deletion and filter them out before doing the crosstab. Managing the batch fields does make this more complicated. If you need to add more complex requirements, I would look at this solution and the one @danilang provided and decide which is better suited to your situation.

TonyA
Alteryx Alumni (Retired)

I just looked at the data a little more closely. My question about repeating records should be why THOR doesn't appear twice under 987456.

SanthoshRam
5 - Atom

@TonyA

The Name THOR can be multiple times under each batch# but the accnum will differ which is below the name row. The data which I have provided might not be the exact as original data since I have copy pasted the first 2 transaction names THOR and IRONMAN by tweaking few other information but the pattern of the data is exactly the same.

 

The new workflow which you have created looks great, that's exactly what I wanted but there is one more challenge which I am facing,

I have made few changes to the workflow am attaching the workflow for your reference.

The problem is the dynamically created columns till FT1 to FT3 is fixed so I can take out the information what I need by TextToColumn tool but rest FT column are not fixed it may or may not have FT4,FT5... and so on.

I just need first 2 strings from all the other dynamically created FT's starting from FT4. 

Ex. 34.11 XX12 X XXX XXXXXXXX -  I need 34.11 & XX12 as FTC4, FTC4a columns respectively for all FT's

 

How can I do this. Please let me know if you have any question.

TonyA
Alteryx Alumni (Retired)

Added/changed sections in yellow. Fixed a problem with the ReportDate column formula. And I added a section to create columns from the FTx columns.

Please mark any of the responses that helped you solve this as solutions. Also, I'd suggest if you have more questions about the workflow that you create a new message thread so others will be more likely to respond to it.

SanthoshRam
5 - Atom

Awesome! that worked great.

Thank you so much for your time and help.

Labels