Alteryx Designer Desktop Discussions

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

Grouping Items Into 2 groups

JovanieYonson
7 - Meteor

Good day!

 

I am trying to create a macro that will group certain number of data into 2 groups. Each group does not necessarily need to be equal number of members. I need to get all possible groupings.

 

Example: 

 

Data: A,B,C,D (4 items)

 

Possible groupings:

1) A and B,C,D

2) B and A,C,D

3) C and A,B,D

4) D and A,B,C

5) A,B and C,D

6) B,C and A,D

and so on...

 

Any idea is greatly appreciated. Thank you!

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@JovanieYonson 
Good to know you here in this community. 😁

there is a similar question answered by @SPetrie maybe we can take as reference.

https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Generate-all-possible-combinat...

I try not to touch the macro itself and make some process outside.

0911-JovanieYonson.png

JovanieYonson
7 - Meteor

@Qiu san

 

This is great! Thanks a lot for this. The community is truly helpful. Amazing! 🙂👏

SPetrie
13 - Pulsar

I'm glad my macro is able to help more people! :)

@Qiu mentioned that he tried not to touch the actual macro in his solution so I though I would offer my version of a solution that does adjust the original macro.

Since Group 2 is the inverse set of Group 1 and the macro already has knowledge of that inverse set, so we just need to add a few tools to capture it.

macro.PNG

Now the macro will output every combo plus its inverse.

The only additional steps needed would be to clear out "duplicates", assuming that ABC-D is the same as D-ABC.

Workflow.PNG

 

I hope this helps as an alternative example to so the many ways you can attack a problem.

Happy solving!

JovanieYonson
7 - Meteor

@SPetrie Yes, I added some few tools downstream on @Qiu's WF to remove the duplicates, reducing possible combinations by half. 

Thank you for updating the macro! Great tool! 🙂

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels