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

Matrix of combinations

TheOrchyster54
5 - Atom

Hi everyone,

 

I was wondering if anyone had any idea on how to generate a matrix where:

- 1 row is a combination

- 1 column per element possible of a combination

My input is p lists as follows:

List 1List 2 List p
BobBlue Paris
KatieRed London
Karen  Madrid

 

1 combination being one element of list 1, one element of list 2 & one element of list p. For example, "Bob, Blue, Paris" or "Bob, Blue, London" or "Karen, Red, Madrid".

If n_p is the length of the list. The matrix will give n_1*n_2*...*n_p rows and n_1+n_2+...+n_p columns

 

The output wished would be:

CombinationBobKatieKarenBlueRed...ParisLondonMadrid
#110010...100
#210010...010
 ...........................
#n_1*n_2*...*n_p00101...001

 

Thank you very much for your help,

 

Jean

3 REPLIES 3
danilang
19 - Altair
19 - Altair

Hi @TheOrchyster54 

 

Tricky little problem.  To solve it, use an iterative macro to generate all the combinations and then split and crosstab.  The first transpose makes it dynamic to handle any number of lists and elements per list

 

MainMain

 

MacroMacro

 

danilang_2-1633789745343.png

 

 

Dan

 

 

 

 

PhilipMannering
16 - Nebula
16 - Nebula

Secondary to @danilang , here's another solution,

PhilipMannering_0-1633799733531.png

 

TheOrchyster54
5 - Atom

Wow great, thank you very much both of you! 

Still starting with Alteryx, didn't know we could embed Python code, it's wonderful :o!

I thought I was forced to do it in 2 steps, output in .csv, open Jupyter NoteBook and then go again in Alteryx!

Labels
Top Solution Authors