Alteryx Designer Desktop Discussions

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

Separate data into groups based on conditions

MinhTa
7 - Meteor

Hello,

 

I am trying to create a system that gets an input file containing conditions and a database file and the workflow groups the database based on the conditions file. The database and condition is shown below. The database contains different file names and customers (in the sample, we have 2 files Sample1.csv and Sample2.csv). The condition file contains the members of each group. For example, in the file sample1.csv, we have 3 groups: group1 contains customer A and B, group2 contains customers C and D, and group3 contains the remaining customer left in the sample1.csv (which is customer E and F). For sample2.csv, we have 2 groups: group1 contains customer G and H and group2 contains the remaining customers in Sample2.csv (which is customer M). The output of the sample is displayed below, whenever a new group is formed, they have headers File Name and Customer1. I would like the workflow able to adapt to the changes in the condition file, just simple changes . For example if I add a new condition column called Group3 that contains E, after I run the workflow, it will form a new group for E. The output after adding Group3 is shown below.

 

Thank you.

 

Condition image:

MinhTa_2-1626631796474.png

 

Database image

MinhTa_1-1626631469844.png

Output:

MinhTa_3-1626631832190.png

 

Output of Sample1.csv after adding group3 to condition file:

MinhTa_4-1626632169784.png

 

Here are the sample database and condition:

 

 

1 REPLY 1
atcodedog05
22 - Nova
22 - Nova

Hi @MinhTa 

 

Here is how you can do it.

 

Workflow:

atcodedog05_0-1626674667646.png

 

Uppers branch

1. Using transpose tool to convert group columns to rows.

2. Using text to col to splits groups range into separate rows.

3. Filtering empty rows and data cleansing.

 

Lower branch

1. Using find & replace tool mapping group based on customers.

2. Using multi-row formula to flag start of new group.

3. Using gen row generating a row when new group starts.

4. Using formula tool to replace newly created row to "customer1". This way separator row is added.

5. Using select tool to keep only required columns.

 

Hope this helps : )

 

Labels