Search code examples
excelarray-formulas

Excel - Count of entries below cumulative threshold without helper column


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

Solution

  • 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)
    

          aggregate_max_less_than