Alteryx Designer Desktop Discussions

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

Finding all possible combinations of each value

richard_gardner
7 - Meteor

I'm struggling with how to solve the following problem: I have a list of id's and values. The number of values associated to each id can be as low as one and as high as 24. I need to create a list of all possible combinations of values for each id.  Below is an example of the input and the expected output. Any suggestions on how I could solve this?

 

Input

idValue
117
1552
217
258
2120
3120

 

Expected Output

idCombo 1Combo 2Combo 3Combo 4Combo 5Combo 6Combo 7
1175217, 552    
2175812017, 5817, 12058, 12017, 58, 120
3120      

 

28 REPLIES 28
LiuZhang
9 - Comet

Good job @chukleswk, let's wait and see if there is more requirement about it. 

In the main time, suggest it to Alteryx challenges 😁

chukleswk
11 - Bolide

@LiuZhang I was thinking the exact same thing after I got through my first little attempt at it! I was going to sit don and run the whole thing with 28+ entries overnight to see how long it would actually take.

 

@richard_gardner if this works or you, then could you please accept @LiuZhang's solution so that others may find it!

richard_gardner
7 - Meteor

Thank you @LiuZhang and @chukleswk  for all of your help with this. No permutations are needed for my use case, so I wrapped this in a batch macro and it worked perfectly. Thank you so much!

Hiblet
10 - Fireball

For others who come looking for a general tool for working out Combinations, I have a macro up on the Public Gallery that will "pick k items from a list of n items" as a combination, using an MIT algorithm based on the fact that binary numbers are unique combinations of 1 and 0.  Find it here... https://community.alteryx.com/t5/Public-Community-Gallery/Combinations/ta-p/1023099

 

@LiuZhang can you please help me, absolutely awesome macro. I have a problem statement on similar lines, but a small tweak

I am looking to create combinations based on groups

Attached is a sample where in I have 4 groups and associated numbers. not sure how I can use your macro to get them to give me combinations by group 

 
 

Combi.PNG

 

Hiblet
10 - Fireball

@Deepakchandrashekar Is this the sort of expected result...

 

ComboExample.png

 

I have not put the combinations into columns, as this format is easier to paste, and it is trivial to change the format, but the image should show the results clearly.

Yes , @Hiblet

Basically looking to cover all combinations in a given group.

 

THank you for helping me out 

 
  
Hiblet
10 - Fireball

@Deepakchandrashekar Attached is an export of the flow.  The flow calls a batch macro, which in turn wraps my ComboMonster macro (available on the Gallery).  I basically pack each task for the ComboMonster into one record, and the batch macro pushes those packed records one at a time.  Beware putting data into this where you have 10 or more items in the group, as combinations become huge very quickly.

 

Quick Plug: I am a contractor for Continuum Jersey, we are a consultancy who specialise in Financial and Automation solutions, and we are strongly pushing into AI and how AI can be used today by businesses.  You might be interested in this ChatGPT connector...  https://community.alteryx.com/t5/Community-Gallery/OpenAI-ChatGPT-4-Completions-Connector/ta-p/11163...

 

@hiblet thank you so much for this macro, I had to make some tweaks to suit my need... but it works like a charm.... 

 

on the AI solution, I will check with my company if we could access them and keep you posted..

 

Hiblet
10 - Fireball

Great, good to know that it is useful.  On the AI side, the ChatGPT connector is effectively just a wrapper to make calls to the OpenAI API endpoints, so if your company allows this, then the macro would be useful.  It is only a macro because this allows me to make the calls throttled, and to make repeated calls if the endpoint is busy.  Good luck, Steve.

Labels