The number of combinations, or more precisely, unique n-tuples, grows fast as the number of values increases. With 20 values, you get about one million tuples which together contain about 20 million elements in the matrix. That is too much to handle comfortably in a spreadsheet.
On the other hand, with 15 values, you only need to generate about 30,000 tuples and about 650,000 elements which is much more manageable. To do that, first calculate the Cartesian product, then filter, sum and format the result, like this:
=let(
values, torow(A2:A, 1),
zeros, map(values, lambda(_, 0)),
table, { zeros; values },
blank, iferror(1/0),
first_, lambda(array, tocol(choosecols(array, 1), true)),
rest_, lambda(n, choosecols(table, sequence(1, columns(table) - n, n + 1))),
wrap_, lambda(array, wrapCount, wraprows(tocol(array, true), wrapCount)),
cartesian_, lambda(a, b, wrap_(
byrow(a, lambda(row,
reduce(blank, sequence(rows(b)), lambda(acc, i,
{ acc, row, chooserows(b, i) }
) )
) ),
columns(a) + columns(b)
) ),
iterate_, lambda(
self, a, b, if(iserror(b), a,
self(self, cartesian_(a, first_(b)), rest_(columns(a) + 1))
)
),
cartesian, iterate_(iterate_, first_(table), rest_(1)),
sums, byrow(cartesian, lambda(row, sum(row))),
expressions, byrow(cartesian, lambda(row, join(" + ", filter(row, row)))),
sort(unique(filter({ expressions, sums }, sums)))
)
The question leaves it unclear whether individual values should be repeatable, and if so, how many times each value should be repeated at most. If you want to repeat each value at most twice, use a values list like 1, 1, 2, 2, 3, 3, 4, 4
.
Here's an example of the results with 4 values:
Values |
Descriptions |
Sums |
1 |
1 |
1 |
2 |
1 + 2 |
3 |
3 |
1 + 2 + 3 |
6 |
4 |
1 + 2 + 3 + 4 |
10 |
|
1 + 2 + 4 |
7 |
|
1 + 3 |
4 |
|
1 + 3 + 4 |
8 |
|
1 + 4 |
5 |
|
2 |
2 |
|
2 + 3 |
5 |
|
2 + 3 + 4 |
9 |
|
2 + 4 |
6 |
|
3 |
3 |
|
3 + 4 |
7 |
|
4 |
4 |