Number.Combinations
How many ways there are to choose a number of items from a set, when the order of the choice doesn't matter.
Group: Number. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Number.Combinations(setSize as nullable number, combinationSize as nullable number) as nullable number
| Parameter | Type | Description |
|---|---|---|
setSize | nullable number | How many items there are to choose from. |
combinationSize | nullable number | How many to choose. |
Returns
nullable number. The count of different selections; 0 when more are chosen than there are.
Remarks
- Both numbers must be whole and not negative: a fraction or a negative number is an error. null gives null.
- Large counts are numbers like any other, kept to about 15 significant digits.
Examples
Two-product bundles from five products
Number.Combinations(5, 2)
10
Chair with desk is the same bundle as desk with chair.
Choosing more than there are
Number.Combinations(5, 6)
0