Livio/ August 3, 2018/ Power BI, Power Query/ 2 comments

Generating Combinations in Power Query

In this post I wanted to share the function I have created to generate combinations in Power Query. The function will accept two parameters. The first parameter is a list you want to use to generate the combinations, the second parameter is a number representing the number of items for each combination. 

In terms of speed there is probably room for improvement as the function may take a few minutes for very large combinations. I will probably revisit it again in the future but for the moment it gives me the results I wanted. Also it would be good if someone can suggest how it could be sped up for large combinations.

The function:


Calling the function:

I will show below how to call the function and the preview of the results you would get


let Source = {"Red","Green","Yellow","Brown","Black","Purple","Pink","Blue","Orange"} in fnGenerateCombinations(Source,4)

Combinations in Power Query



Combinations in Power Query

Combinations in Power Query


Of course you are not limited to a list containing text, it could very well be a list of number, or a list of records, or a list of tables or a list of lists.




  1. Very informative article, great work
    thanks for sharing, Keep up the good work!

    1. Thank you Shobi! Your feedback is very much appreciated.

Leave a Comment

Your email address will not be published. Required fields are marked *