Number.Combinations

Number

Returns the number of combinations for choosing k items from a set of n items, where order does not matter (C(n,k)).

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Number.Combinations(setSize as nullable number, combinationSize as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
setSizenumberYesThe total number of items in the set (n). Must be a non-negative integer.
combinationSizenumberYesThe number of items to choose (k). Must be a non-negative integer <= setSize.

Return Value

numberThe number of unique combinations C(n,k) = n! / (k!(n-k)!).

Remarks

Number.Combinations computes the binomial coefficient C(n, k) — read as "n choose k". It returns the number of ways to select combinationSize items from a collection of setSize items when order does not matter. Two selections are considered identical if they contain the same elements regardless of the order chosen.

The formula is: C(n, k) = n! / (k! × (n − k)!)

Key properties: - C(n, 0) = 1 — there is exactly one way to choose nothing - C(n, n) = 1 — there is exactly one way to choose everything - C(n, 1) = n — choosing 1 item gives n possibilities - C(n, k) = C(n, n−k) — symmetry: choosing k is equivalent in count to leaving out k

When combinationSize > setSize, the result is 0 (impossible selection). Results can grow extremely large for large inputs — C(100, 50) exceeds 10^29, which exceeds double-precision integer precision.

For ordered selections (where order matters), use Number.Permutations instead. Number.Permutations(n, k) = Number.Combinations(n, k) × k!.

Examples

Example 1: How many 2-item subsets can be chosen from 5 items?

Result
Result
110

Example 2: Lottery probability — how many ways to choose 6 numbers from 49?

Result
Result
113,983,816

Example 3: Edge cases and symmetry property of combinations

#table(
    {"k", "C(5,k)"},
    {
        {0, Number.Combinations(5, 0)},
        {1, Number.Combinations(5, 1)},
        {2, Number.Combinations(5, 2)},
        {3, Number.Combinations(5, 3)},
        {4, Number.Combinations(5, 4)},
        {5, Number.Combinations(5, 5)}
    }
)
Result
k
C(5,k)
101
215
3210
4310
545
651

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks