Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Permutation & Combination

Johnny8672
5 - Atom

In Excel, it is quite easy to compute Permutation and Combination using the formula - Permute(x,y) & Combin(x,y)

However, there is no similar function in Alteryx

Ask is to 

1. To compute Permutation - xPy using Alteryx and make x dynamic

2. List out all the possible output. e.g. input: 2C3, Output: (1,2);(1,3);(2,3)

 

Thanks!

4 REPLIES 4
danilang
19 - Altair
19 - Altair

Hi @Johnny8672 

 

There's an idea open to have Alteryx add the factorial function to the list of standard functions, but until that happens, here's a workflow that reproduces the functionality of the Combin and Permute functions and answers part 1 of your original post.

 

MainMain

The main workflow parses expression of the nOr, n is the number of items to choose from, O is the operation either C or P and r is the number of items to choose at time, i.e. 3C2.  After calculating (n-r), which is used in calculating both the number of combinations and permutations, n, r and (n-r) are passed to the factorial macro.  The outputs are combined by record position and the formula tool uses either n!/(n-r)! Permutations or n!/r!(n-r)! Combinations to generate the results

 

MacroMacro

The Factorial macro is a standard macro that generates a row for each of n rows and multiplies the row numbers together.

 

The results are as follows

 

r.png

 

Dan

 

PhilipMannering
16 - Nebula
16 - Nebula

@danilanghas given the best pure Alteryx solution. Personally, I'd prefer to do this statistical stuff not explicitly covered by Alteryx tools in the R or Python tool. Both have functions that do this directly. It's a shame there's not factorial function in the Formula Tool. 

 

If you need help doing combinations and permutations in R or Python let me know and I can probably mock something up.

 

P

Johnny8672
5 - Atom

Thanks for the reply. It solves the problem mathametically by replicate the factorial formula.

 

By the way, how about the second part. By knowing 3P2= 6 and 3C2 =3, how could I have all the possible combinations

 

My thought was to use append function and remove the lines if one "number" appear more than once, but dont have a clue to do that : (

PhilipMannering
16 - Nebula
16 - Nebula

I don't really understand what you mean by Input: 3C2.

 

But if you have a list of items you can find all permutations and combinations by appending it to itself. See example,

WorkflowWorkflow

 

Labels