Excel - Count of entries below cumulative threshold without helper column - excel

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)
      

I prefer the following array formula** due to its non-volatility:
=MATCH(TRUE,MMULT(0+(ROW(B1:B17)>=TRANSPOSE(ROW(B1:B17))),B1:B17)>=0.8,0)-1
Regards

The most succinct way to do it I've found is
=SUM(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))
entered as an array formula, or, equivalently,
=SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))

Related

Finding a sum from based off value from adjacent column

Bit of a silly question, but i've got a small logic problem with an excel formula
If ive got 2 rows of various values, such that it looks like:
A B
1 101
2 150
3 200
4 50
5 70
6 20
How do I find the sum of all values under 'B' that are adjacent to a value in 'A' that is greater than 3?
So essentially it would add up only 50, 70 and 20, as those are adjacent to 4, 5 and 6.
Currently I've got:
=SUMIF(H5:H11,INDEX(B1:B6,MATCH("<3",A1:A6,-1),B1:6))
Naturally this is going to be used with a much larger data set, of a few thousand values - so any advice would be incredibly appreciated.
Thank you!!
Try this formula:
=SUMIF(A1:A6,">3",B1:B6)
Returns 140

Subtotals grouped by value using COUNTIF to create ranges for SUMIF, but in a single formula

End-goal: A column with the subtotals of groups (defined in the below table as all foods listed above Zucchini, incl Zucchini).
Current attempt: create a column to define groups using COUNTIF('count all 'zucchini' thus far'). Then use SUMIF to get the total cost for the current group.
Problem: I don't know how to do this without the COUNTIF column (since SUMIF needs range C:C to be resolved first). I'd like to have it in a single formula. I looked into array formulas but not sure if/how to apply that here.
FOOD COST COUNTIF(A2:A$2;"Zucchini") SUMIF(C:C;C2;B:B)
Apple 3 0 12
Pecan 7 0 12
Zucchini 2 0 12
Apple 4 1 23
Olive 8 1 23
Pecan 6 1 23
Zucchini 5 1 23
Apple 4 2 16
Olive 9 2 16
Zucchini 3 2 16
Any ideas on how to solve either the current problem or the end-goal problem? Thanks!
Put this in C2 and copy down:
=IF(A2="Zucchini",SUM($B$1:B2)-SUM($C$1:C1),"")
It basically sums everything to the row and subtracts what is already accounted for.

VLOOKUP function does not work

I want to implement a simple lookup that uses the classes below and the corresponding grade.
Class Grade
From to
19 20 1
17 18 1,5
14 15 2
12 13 2,5
10 11 3
7 9 3,5
4 6 4
2 3 4,5
0 1 5
In my example I have the search criterion 14 which should give out the grade 2.
Assuming the matrix to be located in the cells A1:C11 and the search criterion in cell E10, the following function gives me the value of 5, but why? The 3 in the formula refers to column 3, which is the value I want to receive.
=VLOOKUP(E10;A1:C11;3)
Thank you for your useful hints and help!
Try,
=index(c:c; match(e10; a:a; -1))
The default True for approximate lookup in VLOOKUP wants the data sorted in ascending order, not descending. MATCH uses 1 for ascending and -1 for descending.
Your Vlookup is missing the last parameter
=VLOOKUP(E10;A1:C11;3) returns an approximate result.
=VLOOKUP(E10;A1:C11;3;0) returns the exact result of your search.

array based on max and less than?

I'm not sure if I'm over complicating this...
basically I'd like to have a formula which is
if the c column is less than 6, then look up the max value in B but display the value of C
so far I have this but I'd like it to show 2, not 437
{=MAX(IF(C2:C12<6,B2:B12, 0))}
any advice is appreciated. i'm shy, be nice..thanks
A B C
cat 110 3
dog 148 4
rooster 36 7
duck 32 8
pig 437 2
horse 44 6
eagle 215 5
dolphin 21 1
panda 2 9
iguana 257 10
fish 199 11
edit:
maybe something like
{=INDEX(C2:C12,MATCH(MAX(IF(C2:C12<6,C2:C12)),C2:C12,0))}
but I don't see where to put b2:b12
You really need two conditions
1) Column B is equal to =MAX(IF(C2:C12<6,B2:B12))
2) Column C is <6
so you can INDEX column C when those two are met, i.e.
=INDEX(C2:C12,MATCH(1,(B2:B12=MAX(IF(C2:C12<6,B2:B12)))*(C2:C12<6),0))
confirmed with CTRL+SHIFT+ENTER
{=IF(C2<6,INDEX($C$2:$C$12,MATCH(MAX($B$2:$B$12),$B$2:$B$12,0)),0)}
You were almost there..
Basically if C<6 , find max of B , lookup it in B:C and display corresponding C
{=IFERROR(VLOOKUP(MAX(IF(C2:C12<6,B2:B12, 0)),B2:C12,2,FALSE),0)}
Since your question doesn't clarify what if c>=6 I assume you don't want value.
Can answer more precisely if you clarify.
Mark this as answer if that's correct.
Hope this helps!
As I could see you requested a single INDEX formula:
{=INDEX($C$2:$C$12,MATCH(MAX(IF($C$2:$C$12<6,$B$2:$B$12,0),0),IF($C$2:$C$12<6,$B$2:$B$12,0),0))}
This is an array formula, hit Ctrl+Shift+Enter while still in the formula bar.
Lets break this down.
=INDEX(C:C, - Index column C as these are the values you want returned
MATCH(IF(C:C<6,B:B,0), - Find the largest value from the following array in the array and return it's relative position for INDEX()
IF(C:C<6,B:B,0),0)) - If the value in column c is less than 6 then add the column B value to the array, otherwise add 0

Excel: Find the minimal value in a column

An Excel table consists of two columns (e.g., A1:B5):
0 10
1 20
3 30
2 20
1 59
I need to get the minimal value in column B for which the corresponding value in column A is greater than zero. In the above example it should be 20.
I tried using various combinations of INDEX(), MIN(), IF(), ROW(), array formulas, etc. - but I just can't figure out how to do it. :-( Any help would be appreciated.
Grsm almost had it
if you enter the following formula in C1 as an array (Ctrl+Shift+End)
=MIN(IF(A1:A5>0,B1:B5))
That should do the trick.
I think you have to make an extra column..
A B C D
0 10 false 20
1 20 20
3 30 30
2 40 40
1 50 50
column C : =IF(A1>0;B1)
cell D1: =MIN(C1:C5)
You need to do it in 2 stages
First use the MIN function to find the minimum
Then take that answer and use the LOOKUP function to select the row and column that you need.
Check the "Minimum And Maximum Values In A Range" example in http://www.cpearson.com/Excel/excelF.htm (you can download the same as well from the same section)
HTH
This is not identical, but very similar: Excel VBA - Find minimum of list of values?

Resources