From a list I would like to generate combinations of n members from a set of x possibilities in Power Query.
I have found some useful code here on creating combinations of members based on all possible values of n, and here on generating permutations for x, but I regret that I'm not good enough at PQ to figure out how to adapt them.
For background, here is the real-world scenario. We have 19 vendors who have bid on providing 1,728 surgical items. The size of their discount varies depending on what percentage of our business (represented by how many other vendors will supply the same item) they receive. They offer pricing based on single vendor, 3-vendor, 5-vendor, and 8-vendor participation. (Yes, single sourcing is clearly the cheapest route but none of the vendors offer all 1,728 items.) So at each level of vendor participation we would like to know the cheapest combination of vendors.
(These are combinatorials rather than permutations since ABC is equivalent to BAC, CBA, and so on. The order in which vendors A, B, and C appear does not affect pricing.)
By generating these combinations we can then merge the price file from each vendor and use Power Pivot to determine which combinations do not offer all 1,728 items, which ones might offer more than one option/price for a particular item, and rank the combinations based on pricing times our historical usage of each item - taking the MIN price for items offered by each vendor within the combination.
I don't have a need for the same concept for permutations (generating n permutations from a set of x) but I suppose it would come in handy for someone!
I have found some useful code here on creating combinations of members based on all possible values of n, and here on generating permutations for x, but I regret that I'm not good enough at PQ to figure out how to adapt them.
For background, here is the real-world scenario. We have 19 vendors who have bid on providing 1,728 surgical items. The size of their discount varies depending on what percentage of our business (represented by how many other vendors will supply the same item) they receive. They offer pricing based on single vendor, 3-vendor, 5-vendor, and 8-vendor participation. (Yes, single sourcing is clearly the cheapest route but none of the vendors offer all 1,728 items.) So at each level of vendor participation we would like to know the cheapest combination of vendors.
(These are combinatorials rather than permutations since ABC is equivalent to BAC, CBA, and so on. The order in which vendors A, B, and C appear does not affect pricing.)
By generating these combinations we can then merge the price file from each vendor and use Power Pivot to determine which combinations do not offer all 1,728 items, which ones might offer more than one option/price for a particular item, and rank the combinations based on pricing times our historical usage of each item - taking the MIN price for items offered by each vendor within the combination.
I don't have a need for the same concept for permutations (generating n permutations from a set of x) but I suppose it would come in handy for someone!