I have assigned 10 assessments in my class. The students can do all 10 but only their top 8 marks will count. I would like to use a formula that takes an average of the top 8 marks from 10 (in other words, it excludes the lowest two marks from the range).
I've tried to take an average of the top 8 marks but it gives me a reading over the top 8 rows. I used:
=AVERAGE(LARGE(B2:K2,ROW(1:8)))
Where my range of data is in Row 2, Columns B - K.
In order to average top/bottom values you need to use array formula:
You code is correct, simply press Ctrl+Shift+Enter to apply it as an array formula.
You formula will be surrounded by curly brackets:
{=AVERAGE(LARGE(B2:K2,ROW(1:8)))}
If you want to enter the formula normally, you can use
=AVERAGE(LARGE(B2:K2,{1,2,3,4,5,6,7,8}))
or
=AVERAGEIF(B2:K2,">"&SMALL(B2:K2,2))
or
=AVERAGEIF(B2:K2, ">=" & LARGE(B2:K2,8))
So how about :
=(sum(b2:k2)-sum(small(b2:k2,{1,2})))/8
Tested and works, but if the { don't work then:
=(sum(b2:k2)-sum(small(b2:k2,1)+small(b2:k2,2)))/8
Related
Need your help on below.
I would like to sum all the action count (the action count need to be divided 5 first then round up before summing it all up ) if criteria(Action type) is "A".
I tried to use the formula
=sumif(B2:B6,"A",roundup((A2:A6/5),0))
I tried to press ctrl+shift+enter to make it as a array formula but I prompt error. And the result I want is 4 from the above formula.And if the criteria change become "B" the result will be 5.
I tried to find a way in Google but unable to find any solution.
Try an old style (pre-SUMIF) style of array formula.
=SUM(IF(B2:B6="A", CEILING(A2:A6/5, 1)))
Finsih with CSE.
In a Column I'm counting score per ball, are like
10-25
10 balls 25 Runs.
I've data in Range A2:A10 and I'm using the following formula but getting Zero.
=SUMPRODUCT ((LEFT(A2:A10, FIND("-", A2:A10) - 1))&"-"&SUMPRODUCT ((MID(A2:A10, FIND ("-", A2:A10) +1,10))+0))
NB : It's an Array formula.
This should fix it
=SUMPRODUCT(LEFT(A2:A10,FIND("-",A2:A10)-1)+0)&"-"&SUMPRODUCT(MID(A2:A10,FIND("-",A2:A10)+1,10)+0)
You needed to add +0 in both SUMPRODUCT's to get the strings to behave as numbers and also the brackets weren't quite right
suppose I have a set of rows with numbers. Some columns in these rows are blank. Each row however contains an even number of non-blank cells as follows:
row_1: 3 4 # 7 # 3
row_2: 5 # 3 7 # 8
row_3: # # 5 # # 3
...
where # is an empty cell.
I would like to find a formula that will compute the following (using row_1 as an example):
= -3 + 4 + -7 + 3
In other words, the formula is to compute the sum of non-blank cells where the value of every odd non-blank cell has an inverted sign.
Question: Is it possible to do it without VBA just with some excel formula? Any help is appreciated.
Based on data in A1:F1, array formula**
=SUM(INDEX(1:1,N(IF(1,MODE.MULT(IF(A1:F1<>{"";""},COLUMN(A1:F1))))))*-1^ROW(INDEX(A:A,1):INDEX(A:A,COUNT(A1:F1))))
Copy down to give similar results for data in A2:F2, A3:F3, etc.
As way of an explanation, using the data provided, this part:
N(IF(1,MODE.MULT(IF(A1:F1<>{"";""},COLUMN(A1:F1)))))
produces an array of column indices for which the entry within row 1 of that column is non-blank, i.e.:
{1;2;4;6}
We then pass these to INDEX, such that:
INDEX(1:1,N(IF(1,MODE.MULT(IF(A1:F1<>{"";""},COLUMN(A1:F1))))))
which is:
INDEX(1:1,{1;2;4;6})
gives:
{3;4;7;3}
which is then multiplied by the result of:
-1^ROW(INDEX(A:A,1):INDEX(A:A,COUNT(A1:F1)))
which is:
-1^ROW(A1:A4)
i.e.:
-1^{1;2;3;4}
i.e.:
{-1;1;-1;1}
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
How does this work? You'll need to use helper columns. (There may be a way to skip that and combine the helper formula with Sum(), but I'm not there yet :P )
The formula to put in H1, and drag right/down is:
=IF(A1<>"",IF(MOD(COUNTA($A1:A1),2)=1,-1*A1,A1),"")
Then just sum up those numbers (column O above) to get your answer.
In column G, use the following formula:
=CONCATENATE(A1,B1,C1,D1,E1,F1)
Then in column H use this formula:
=-MID(G1,1,1)+MID(G1,2,1)+IF(LEN(G1)>2,-MID(G1,3,1)+MID(G1,4,1),0)
This is assuming you only have six columns, at least two of them are always filled in, and at least two will be blank. If you fall outside of that criteria, you will have to additionally modify it.
I want to know how many cells it take to sum N. Please see following example:
number | cells to sum of 100
100 | 1
50 | 2
20 | 3
25 | 4
15 | 4
90 | 2
10 | 2
See the last column, it find the min number of current cell + previous cells to sum of 100.
Is there a way to do so?
Thanks.
In B2, array formula**:
=IFERROR(1+ROWS(A$2:A2)-MATCH(100,MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2)))),-1),"Not Possible")
Copy down as required.
Change the hard-coded threshold value (100 here) as required.
As way of an explanation as to the part:
MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2))))
using the data provided and taking the version of the above from B5, i.e.:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
the first part of which, i.e.:
TRANSPOSE(A$2:A5)
returns:
{100,50,20,25}
and the second part of which, i.e.:
0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5)))
resolves to:
0+({2;3;4;5}>=TRANSPOSE({2;3;4;5}))
i.e.:
0+({2;3;4;5}>={2,3,4,5})
which is:
0+{TRUE,FALSE,FALSE,FALSE;TRUE,TRUE,FALSE,FALSE;TRUE,TRUE,TRUE,FALSE;TRUE,TRUE,TRUE,TRUE})
which is:
{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1}
An understanding of matrix multiplication will tell us that:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
which is here:
MMULT({100,50,20,25},{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1})
is:
{195,95,45,25}
i.e. an array whose four elements are equivalent to, respectively:
=SUM(A2:A5)
=SUM(A3:A5)
=SUM(A4:A5)
=SUM(A5:A5)
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
I did the first 3 with an excel formula:
D3>100
C4 is where your numbers start, so C4=100, C5=50 etc.
Formula is on D4, D5, D6 etc
On D4:
=IF(C4>=D3;1;"False")
On D5:
=IF(C5>=D3;1;IF(C5+C4>=D3;2;"Error"))
On D6:
=IF(C6>=D3;1;IF(C6+C5>=D3;2;IF(C6+C5+C4>=D4;3;"Error")))
You can keep doing this, just keep replacing "Error" with an longer/updated version of IF(C6+C5+C4>=D4;3.
I don't know if this is the best way, but this will achieve it.
One way to solve this is to create an NxN matrix of equations instead of just a column. An example picture is provided. Columns E through I are hidden. The last column on the right determines the number required
Theoretically, you can also hard code the equations if the number of rows needed to get to 100 is a known small number. For example, if the number of rows is always four or less, C8 would be =IFS(B8>=100,1,SUM(B7:B8)>=100,2,SUM(B6:B8)>=100,3,SUM(B5:B8)>=100,4). BTW, you'll run into sum boundary problems with this equation on the first, second, and third rows. Therefore, the first row will need to be =if(B8>=100,1,""), the second row would be =IFS(B9>=100,1,SUM(B8:B9)>100,2,TRUE,"") and so on.
I'm trying to use this formula:
=SUMPRODUCT(VLOOKUP(B$4778,$D$4:$DC$4623,{4,5},0))
It works fine but I'd like to try to use a variable for the {4,5} portion of the formula (columns in the array to be summed) as the formula needs to change based on sheet inputs before this formula.
I have cells on the sheet that are to be used to set the initial and final columns to be searched (likely 10 columns, but the 10 columns would have to be selected from 90 some columns available).The columns are populations related to each age. So, if I need population of those aged 10 through 15, I'd need to sum up 5 columns. If 20-25, need to sum up 5 different columns.
I tried to use the Columns function but it didn't seem to work for me.
The columns are selected by users entering in cells the upper and lower limits of the search range and then I convert those values to the corresponding numerical column value.
So if they select 5 as lower and 10 as upper limit, I know I have to add 7 to get the correct data column on the data page (column 12) and likewise for upper (column 17).
The entire possible area to search is $D$4:$DC$4623. So, in the formula, if I wrote it out long way it would be:
=SUMPRODUCT(VLOOKUP(B$4778,$D$4:$DC$4623,{12,13,14,15,16,17},0))
I'd prefer to write it out using variables, something like this:
=SUMPRODUCT(VLOOKUP(B$4778,$D$4:$DC$4623,{L:U},0))
Where variable L would be 12 and variable U would be 17.
Can anyone suggest a way to write the formula?
use this array formula:
=SUM(VLOOKUP(B$4778,$D$4:$DC$4623,ROW(INDIRECT(D5 & ":" & E5)),FALSE))
Where D5 is the Lower and E5 would be the upper.
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then excel will put {} around the formula.
Or better yet use this non array formula:
=SUM(INDEX($D$4:$DC$4623,MATCH(B$4778,$D$4:$D$4623,0),D5):INDEX($D$4:$DC$4623,MATCH(B$4778,$D$4:$D$4623,0),E5))