且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel - 在没有帮助列的情况下低于累积阈值的条目数

更新时间:2023-12-06 17:11:34

您并不是真的在寻找

I have the following little table. I'd like a formula that finds the number of values where the cumulative total (of column B) is less than some threshold (tx).

I tried

{=MIN((SUM(OFFSET(B1,0,0,A1:A17))>tx)*A1:A17)-1}

but OFFSET doesn't seem to be arrayable like that. Obviously, this would be trivial with a helper column, but for certain reasons that is not possible.

So the correct answer here should be 10.

tx = .8

A   B
1   0.112106465
2   0.110981698
3   0.091959216
4   0.082163441
5   0.073292066
6   0.072407529
7   0.071646289
8   0.061646797
9   0.06011448
10  0.057566381
11  0.050341978
12  0.048227061
13  0.043207335
14  0.03940462
15  0.012914194
16  0.007603446
17  0.004417003

You're not really looking for a MIN; rather it should be MAX that follows your condition.

In E7 as a standard (non-array) formula,

=AGGREGATE(14, 6, ROW(1:17)/(SUBTOTAL(9, OFFSET(B1, 0, 0, ROW(1:17), 1))<D7), 1)