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!
Solved! Go to Solution.
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.
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
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
Dan
@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
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 : (