We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Generate different number of rows based on different conditions

AkisM
10 - Fireball

I have a table that looks like this 

 

NameTeamCondition1Condition2
JohnA300
JohnA1517
JohnA50
BobA50
BobA80
BobB045
BobB260
BobB470

 

I would like to generate 1 or more rows, based on how many of conditions1 to x are satisfied, for each different testing group.  A testing group is defined as where the name is the same but the team is different, or where the team is the same but the name is different (or where both change, such as another 3 rows of John with team C). So the first 3 rows are 1 group, The next 2 are another group, and the last 3 are another group. If the first group for example has any row where condition1 isn't 0, then 1 row should be added to that group. If the first group has any row where condition2 isn't 0, then another row should be added to that group. So each group may get an extra 1 or 2 rows.

 

With these rules, the above table should look like this:

 

NameTeamCondition1Condition2
JohnA300
JohnA1517
JohnA50
JohnANullNull
JohnANullNull
BobA50
BobA80
BobANullNull
BobB045
BobB260
BobB470
BobBNullNull
BobBNullNull

 

Any ideas? I know how to get the groupping done, (used sum tool, group by name and group by team, then add record id, then join back to original data by name and group), but not really sure how to do the row testing and generation.

3 REPLIES 3
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @AkisM,

 

I believe this solves the issue you were trying to achieve?

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

AkisM
10 - Fireball

Hi @Jonathan-Sherman , I forgot to mention that there are also negative values in the tests. The max method doesn't account for negative values (the condition should still be true if a test has a negative value since it's not 0)

 

Edit: Fixed by just adding min, and editing formula to say "or min<0". Thanks

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @AkisM,

 

In that case you could use an absolute function ABS() in front of the summarise tools when calculating the extra rows. The originating data would still remain negative if negative before (such as in my example -17)

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached an updated workflow for you to download if needed.

 

Regards,

Jonathan

Labels
Top Solution Authors