我想找到运行总和值达到指定数量的行,并且已满足几个条件(类似于sumif)。
我不能像这里建议的那样添加累积行:
Count rows until the sum value of the rows is greater than a value
....因为我有其他标准要在数据中遇到,因此不能有一个总计。
在下面的虚拟示例中,我想找到“设计”项目花费或超过30,000美元的日期
答案 0 :(得分:0)
制作累积行,只有在B列等于' Design'
时才合计如果您希望能够进行vlookup,则应该创建一个额外的列来检查数量是否超过30k,然后输出任何将成为vlookup的关键字。
答案 1 :(得分:0)
Ok, for anyone who is interested, here is what I ended up doing. I created a separate table that had all of my possible weeks (10/17, 10/24, 10/31, etc.) in one column, and corresponding sequential numbers in the next column. I ended up with 54 in my actual project.
Then, I ended up having to insert one column into my dataset for the purposes of looking up that "Week No", for each "Week" in all rows. Then on my other sheet where I was solving, I had a cell be my decision variable for the week #. I had another be my target $. I created a formula that took my target amount minus the SUMIFS for all of my criteria (Project, Name, etc.) with the last criteria being that the week number had to be "<=" & (decision cell). I then used Solver to minimize the output by changing the target week with constraints that the target week had to be integer, >=1, <=54, and that the output had to be >=0. That got me to the week prior to where the funding went negative. I then had a cell lookup that week number +1 on my weeks table to find the week at which my target amount would be met.
Sorry, had to explain it that way, vs. the actual formula, as my actual formula has a lot of SUMIFS criteria and cell references that wouldn't make any sense here.
答案 2 :(得分:0)
一个较晚的答案,但不使用“帮助者专栏”。
通过在MMULT
d数组上使用矩阵乘法(TRANSPOSE
),确定行是否大于自身以及列表本身,我们可以生成运行总计数组。
MMULT(--(TRANSPOSE(ROW(D2:D21))<=ROW(D2:D21)), D2:D21)
为演示起见,如果我们将其缩小到仅前三行,那么您正在进行此计算:
[[--(2<=2)][--(3<=2)][--(4<=2] [[10,000]
[--(2<=3)][--(3<=3)][--(4<=3] ∙ [ 8,000]
[--(2<=4)][--(3<=4)][--(4<=4]] [ 6,000]]
哪个给我们的:
[[1][0][0] [[10,000] [[10,000]
[1][1][0] ∙ [ 8,000] = [18,000]
[1][1][1]] [ 6,000]] [24,000]]
然后我们可以将其与目标值进行比较,并除以结果以消除具有#DIV0!
错误的值,并使用AGGREGATE
获得最小的非错误值
=AGGREGATE(15, 6, Row(D2:D21) / (MMULT(--(TRANSPOSE(ROW(D2:D21))<=ROW(D2:D21)), D2:D21)<30000), 1)
这将为我们提供第一行,其中“运行总额”> = $ 30,000