所有数字组合的总和(不包括重复Excel) [英] Sum of all number combinations excluding repetition Excel

查看:84
本文介绍了所有数字组合的总和(不包括重复Excel)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该投票最高的答案



此公式将按生成顺序给出总和,但必须是结合第一个公式以正确的顺序获取它们

  = ArrayFormula(mmult(if(mod(int(row(A1 :A15)/(2 ^(column(A1:D1)-1))),2)= 0,0,column(A1:D1)),转置(column(A1:D1))^ 0))

给予此

  = ArrayFormula(sort({& transpose(split(SUBSTITUTE(substitute(textjoin( +,true,{if(mod(int(row(A1:A15)/(2 ^(column(A1 :D1)-1))),2)= 0,,column(A1:D1)),B1:B15&;}), +;,;),; +, ;),;)),ArrayFormula(mmult(if(mod(int(row(A1:A15)/(2 ^(column(A1:D1)-1))),2)= 0,0 ,column(A1:D1)),transpose(column(A1:D1))^ 0))},1,true))



此处显示的是这样确定,如果您使用实际值而不是列号

  = ArrayFormula(sort({&(split(SUBSTITUTE( replace(textjoin( +,true,{if(mod(int(row(A(A1:A15)/(2 ^(column(A1:D1)-1))),2)= 0,,column( A1:D1)),if(row(A1:A15)> 0,;)}), +;,;),; +,;),;)) ,ArrayFormula(mmult(if(mod(int(row(A1:A15)/(2 ^(column(A1:D1)-1))),2)= 0,0,A1:D1),转置(column( A1:D1))^ 0)}},1,true))


this top voted answer Sum all combinations Excel or Google Spreadsheets is close to what I need - however I require a solution where it keeps the combinations in order and excludes repetition based on this order. i.e. a data set of 1 2 3 4 would show the product of:

1 1+2 1+3 1+4 1+2+3 1+2+4 1+3+4 1+2+3+4

2 2+3 2+4 2+3+4

3 3+4

4

i.e

1 3 4 5 6 10

2 5 6

3 7

4

Is this possible in Google Sheets / Excel without a script?

Thanks

解决方案

Here's a formula to display the sums in order

=ArrayFormula(sort(" "&transpose(split(SUBSTITUTE(substitute(textjoin("+",true,{if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,"",column(A1:D1)),B1:B15&";"}),"+;",";"),";+",";"),";")),1,true))

This formula will give the sum totals in the order that they are generated, but then it would have to be combined with the first formula to get them in the right order

=ArrayFormula(mmult(if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,0,column(A1:D1)),transpose(column(A1:D1))^0))

Giving this

=ArrayFormula(sort({" "&transpose(split(SUBSTITUTE(substitute(textjoin("+",true,{if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,"",column(A1:D1)),B1:B15&";"}),"+;",";"),";+",";"),";")),ArrayFormula(mmult(if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,0,column(A1:D1)),transpose(column(A1:D1))^0))},1,true))

Here's how it would look if you used actual values rather than column numbers

=ArrayFormula(sort({" "&transpose(split(SUBSTITUTE(substitute(textjoin("+",true,{if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,"",column(A1:D1)),if(row(A1:A15)>0,";")}),"+;",";"),";+",";"),";")),ArrayFormula(mmult(if(mod(int(row(A1:A15)/(2^(column(A1:D1)-1))),2)=0,0,A1:D1),transpose(column(A1:D1))^0))},1,true))

这篇关于所有数字组合的总和(不包括重复Excel)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆