寻找最有利可图的范围(数学名称:“最大子数组问题”或“最大连续子序列和”)
为了能够找到最有利可图的范围,我将所需的最低值添加到所需的最高值,并创建一个如下例所示的表格:
https://docs.google.com/spreadsheets/d/17zpapBeC5wYxyU6SjbqcbnV4_QP4gooxj0PxdCywDk0/edit?usp=sharing
单元格公式示例:
0
和 0:
=IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D2)*($A$1:$A>=$E$1))))
在5
和10
之间:
=IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D12)*($A$1:$A>=$J$1))))
=MAX(E2:O12)
Max Profit = £185.00
=INDEX(A1:O1,ARRAYFORMULA(MIN(IF(E2:O12=MAX(E2:O12),COLUMN(E2:O12)))))
Value Min for Max Profit = 4
=INDEX(D1:D12,ARRAYFORMULA(MAX(IF(E2:O12=MAX(E2:O12),ROW(E2:O12)))))
Value Max for Max Profit = 10
当A
和B
中有数百个值1时,该表得到非常大而且重,甚至会像我当前的原始数据电子表格一样导致崩溃。
有没有什么方法可以仅使用一个公式或脚本代码来找到最大利润|最大利润的最小价值 |价值最大化以获得最大利润,而不需要逐一执行每个范围,需要使用数千个单元格,每个单元格都有一个特定的公式?
注意:
数百个值 1 → 我的原始电子表格当前在 A
中包含 1471
行数据,结果在 B
中。因此,为了能够进行此分析,我需要输入 2,163,841
公式,例如 =IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D2) )*($A$1:$A>=$E$1))))
在单元格中创建表格并找到最有利可图的范围。
To be able to find the most profitable range, I add the lowest value I want to the highest value I want, with that I create a table like this example:
https://docs.google.com/spreadsheets/d/17zpapBeC5wYxyU6SjbqcbnV4_QP4gooxj0PxdCywDk0/edit?usp=sharing
Cell's formulas examples:
Between 0
and 0
:
=IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D2)*($A$1:$A>=$E$1))))
Between 5
and 10
:
=IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D12)*($A$1:$A>=$J$1))))
=MAX(E2:O12)
Max Profit = £185.00
=INDEX(A1:O1,ARRAYFORMULA(MIN(IF(E2:O12=MAX(E2:O12),COLUMN(E2:O12)))))
Value Min for Max Profit = 4
=INDEX(D1:D12,ARRAYFORMULA(MAX(IF(E2:O12=MAX(E2:O12),ROW(E2:O12)))))
Value Max for Max Profit = 10
When there are hundreds of values¹ in A
and B
, this table gets very big and heavy, even causing crashes like my current original data spreadsheet.
Is there any way using a only one formula or script code to found Max Profit | Value Min for Max Profit | Value Max for Max Profit
without doing each range one by one needing to use thousands of cells each with a specific formula?
Notes:
hundreds of values¹ → my original spreadsheet currently contains 1471
rows of data in A
with the results in B
. So to be able to do this analysis, I need to put 2,163,841
formulas like =IFERROR(SUM(FILTER($B$1:$B,($A$1:$A<=D2)*($A$1:$A>=$E$1))))
in the cells to create the table and find the most profitable range.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最大:
最小值:
最大值:
更新:
max:
value min:
value max:
update: