Calculate the average of the 3 highest grades - excel

I'm relatively new to excel but I am making a gradebook that calculates all of my grades.
One of my classes has an interesting way to calculate grades. There are 4 quizzes, and the lowest one will be dropped (essentially removed from the calculation completely).
How would I go about this, I tried using
=((SUM(D2:D5)-SUM(SMALL(D2:D5,4)))/(COUNT(D2:D5)*100))
on data like this
D2|75
D3|80
D4|83
D5|65
So in this case, I want the 65 to be removed, then calculate the average
I am not getting any error but the average is wrong

Subtract 1 from the count. In the example you are dividing by 4 instead of 3.
Like this:
=((SUM(D2:D5)-MIN(D2:D5))/(COUNT(D2:D5) - 1) * 100

You can average the top 3 out of 4 with this formula
=AVERAGE(LARGE(D2:D5,{1,2,3}))

Add the four tests together, subtract out the min(.) of the same range, and divide the total by 3.
If your scores are in B2, C2, D2, and E2 then something like:
=(SUM(B2:E2)-MIN(B2:E2))/3
Was this helpful?

Related

Excel - dynamically average the top values of a column

I have a column that may contain X number of values. I am looking to get the average of the top Y values, based on the number of X values that are above 0. There are just two rules on how to come to this value.
Y must represent 49% or less of the values greater than 0. If I have 11 total values that are above 0, then I can only take the top 5.39 values that I can take an average on.
Y must be a whole number and rounded down. To take the last piece of criteria further, 5.39 would round down to 5, so I am essentially getting the average of the top 5 values.
I feel like I am getting close with different solutions but have struggled. For instance, the solution at Getting average of top 30% of the values in one column is close, however, it appears to find the values above the 0.7 number, and not necessary the top 30%.
Here is my data,
92.593
88.889
45.679
88.889
0
88.889
87.654
0
69.136
41.975
49.383
0
40.741
50.617
0
Here I have 11 values that are above 0. I know that using the criteria I mentioned above, I can only average the top 5 values. Those top 5 values average out to be 89.383.
I have tried something like this,
=AVERAGE(LARGE(A1:A14), ROW($B$1:$B2)))
Where B1 just has the value 1, and B2 has a formula that calculates the number of values I can have, with no such luck.
I don't know your XL version, but this also works with older versions
=AVERAGE(LARGE(IF(A1:A15>0,A1:A15),ROW(INDIRECT(B1&":"&B2))))
remember to confirm as array formula using CTRL+SHIFT+ENTER
I hope that's what you are looking for,
bye.

Excel - standard deviation where source cells are a count

I have some data that looks like this
Condition 1
Condition 2
Condition 3
Condition 4
Condition 5
0
0
0
70
0
0
50
10
0
0
120
0
0
5
5
Where the value in each cell is the number of meters of an asset that is the given condition. Or in other words, a count of the number of meters that are a '4'.
How do I calculate a standard deviation for this? Obviously the std.dev would be '0' for the first row, higher for row 2, and fairly low for row 3.
Something similar to REPT, but that repeats a value x times in a formula?
I considered a helper column but the number of meters that there are in total makes this impractical.
I am not a math expert, but I can show you how to "make a range of numbers" based on the criteria shown, using Excel 365.
Suppose your data is in the range B2:F4 as shown below. In cell G2, enter the following formula and drag it down:
=STDEV.P(--FILTERXML("<t><s>"&TEXTJOIN("</s><s>",1,REPT($B$1:$F$1&"</s><s>",$B2:$F2))&"</s></t>","//s[number()=.]"))
The above will calculate the standard deviation using the STDEV.P function, but I am unsure if this is the right function to use as there are many other variations to the original STDEV function.
Regardless, the following part of the formula is able to return a range of numbers as desired:
=--FILTERXML("<t><s>"&TEXTJOIN("</s><s>",1,REPT($B$1:$F$1&"</s><s>",$B2:$F2))&"</s></t>","//s[number()=.]")
You can view this question and the answer by JvdV to understand the use of the FILTERXML function.
Another way of doing it is to use the alternative SD formula
which would give you
=SQRT((SUM(A2:E2*COLUMN(A2:E2)^2)-SUM(A2:E2*COLUMN(A2:E2))^2/SUM(A2:E2))/SUM(A2:E2))
for the population standard deviation.
The Excel 365 version using Let is more readable I think:
=LET(x,COLUMN(A2:E2),
mpy,A2:E2,
n,SUM(mpy),
sumxsq,SUM(mpy*x^2),
sumsqx,SUM(mpy*x)^2,
numerator,sumxsq-sumsqx/n,
SQRT(numerator/n)
)
A bit less obviously, you could get it from the original formula
=SQRT(SUM(A2:E2*(COLUMN(A2:E2)-SUM(A2:E2*COLUMN(A2:E2))/SUM(A2:E2))^2/SUM(A2:E2)))
Again, in Excel 365 you could write this as:
=LET(x,COLUMN(A2:E2),
mpy,A2:E2,
n,SUM(mpy),
xbar,SUM(mpy*x/n),
numerator,SUM(mpy*(x-xbar)^2),
SQRT(numerator/n)
)
Change the denominator to
(SUM(A2:E2)-1)
for the sample standard deviation.
I ended up figuring it out.
I added a column which calculated the average. (Say column F)
I then had a formula like this
=SQRT(SUM(A2*POWER((1-F2),2),B2*POWER((2-F2),2),C2*POWER((3-F2),2),D2*POWER((4-F2),2),E2*POWER((5-F2),2))/SUM(A2:E2))
Essentially this calculated the variance from the mean for each condition value, multiplied by the number of values (e.g. number of meters) of asset that are that particular condition, then did the normal other standard deviation calculations (sum, divide by total, square).

Custom SUMPRODUCT()

I have the following table:
My objective is to spread out the 10,000 units across the 5 months, given the weightings below each month. The row adjacent the 10,000 is my best attempt at getting this (I have spent a few hours on this). The yellow is what I am after.
The logic I have tried to use to get the calculation is as follows: Calculate the even spread across the months (in this example 10,000 / 5 = 2,000 = X). Multiply each month weighting to get the weighted amount (in this example to get M2 = 1,600 and M4 = 3,000: X + (X * M2 weighting) etc). You can then take the total 10,000 minus the summation of these which will give you 5,400, which you can then distribute across the months don't don't have a weighting. There must be an easy way to do this with a SUMPRODUCT but I can't seem to figure it out.
My best attempt so far is this:
=IF(B3=0,SUMPRODUCT(ABS((10000/5)*$B3:$F3)),(10000/5)+((10000/5)*B3))
Try the following:
Formula in B3:
=IF(B$2=0,($A3-SUMPRODUCT(($B2:$F2<>0)*(($A3/5)*(1+$B2:$F2))))/COUNTIF($B2:$F2,0),($A3/5)*(1+B$2))
Drag right.
Logic:
=IF(B$2=0,<true>,<false>) - Check if cell above equals zero
If above is false (so other than 0) then: ($A3/5)*(1+B$2) - First divide (10000/5) and multiply that outcome by (1-<percentage>)
If IF yields true - Check which cells in range are other than zero and multiply by the same logic as per step 2. The sum gained with SUMPRODUCT can then be deducted from 10000 and devided by the count of cells that actually do hold zero (hence the COUNTIF).

Using an average of 10 rows for multiple cells, then moving to the average to the next 10 cells

I have a large column of data where every 10 rows is a different set.
What I would like to do is get the average of those 10 rows, and then subtract that from every individual measured value.
Then it moves to the next 10, takes the average of those, and subtracts it from the 10 data points that yielded the new average.
I've tried using MOD and plenty of formulas and dragging out some kind of formula but Excel's pattern recognition is not working at all in this case.
Example of what I'm trying to do using 3 values instead of 10
The output I want takes the average of the first 3 values ((1+2+3)/3=2), then subtracts it from those 3 values and outputs it as the result. (1-2=-1, 2-2=0, 3-2=1). Then it repeats the same thing with the next 3 and the results from the previous 3 do not affect it.
Values________Average_______Result
1|__________________________-1
2|______________2 __________ 0
3|__________________________1
2|__________________________-2
5|______________4 __________ 1
5|___________________________1
2|___________________________-1
5|_____________3_____________2
2|___________________________-1
(I'm so sorry about the awful table)
Any help would be greatly appreciated! Thank you.
Using your data and doing every three:
=A2-AVERAGE(INDEX(A:A,INT((ROW(1:1)-1)/3)*3+2):INDEX(A:A,INT((ROW(1:1)-1)/3)*3+4))
To change to 10 change the each /3 to /10 and *3 to *10 this is the interval. You will also need to change the +2 to the first row of data and the +4 to +11 or +[the interval]-1
I like Scott's answer better, but since I had worked it out while he was typing, I'll add my solution as well.
I'm using the INDIRECT function to build the range reference and calculating the range for the AVERAGE by using MOD on the ROW function.
Basically you're looking to average over the first ten rows, so you need the range A1:A10, then A11:20, and so on. In order to calculate the beginning row, take your current ROW() and subtract the MOD 10 of its previous row: ROW()-MOD(ROW()-1,10). The last row of the group just adds 9 rows: ROW()-MOD(ROW()-1,10)+9.
Everything in Column B uses the formula:
=AVERAGE(INDIRECT("A"&ROW()-MOD(ROW()-1,10)&":A"&ROW()-MOD(ROW()-1,10)+9))

Tie breaking using Rank function

I have a student's result sheet, where I calculated the total number the student has gained. Next, I want to rank them according to the grand total, and wherever it duplicates, the student getting more number in maths(E9:E58) will be given priority,
How to accomplish it?
I have my grand total from U9 to U58, and maths score in d9 to d58.
I have used this formula:
=Rank(u9,u9:u58,1)
I am stuck in how to use the if condition within the rank function.
Please help.
Thanks in advance....
In that sort of situation, one method of adjusting is to use the SUMPRODUCT function. You will need to adapt my example to your data ranges. In the example below, you don't need columns E:F. They are only there so you can better see how the adjustment is accomplished.
Adjustment Function:
=SUMPRODUCT((C2=Totals)*(B2>Maths))
adj Rank Function
D2: =RANK(C2,Totals,1)+SUMPRODUCT((C2=Totals)*(B2>Maths))
Assuming, Total score is in Column U and Math's score is in Column E, you can use Ron's solution as:
=RANK(U9,U$9:U$58)+SUMPRODUCT((U$9:U$58=U9)*(E$9:E$58<E9))
Enter above formula in 9th row of the column where you want Rank to be displayed and then drag/copy it down till 58th row.
This is more of arithmetic approach. I would add a column called adjusted total.
AdjTotal = Total + (Maths Score / Max possible Maths Score) * 0.9
Then use this Adjusted score column to rank.
The adjustment will add a fraction under 1 to the total and will help break the tie when there is one. Since the adjustment will never be more than 0.9 it will not affect ranks when there is no tie.
Assuming Max score for Maths is 100, use this
V9 = U9 + D9/100*0.9
Copy V2 down till V59
W9 = RANK(V9, V$9:V$59, 1)
Copy W9 down.
You can do this by running the usual RANK() method and then adding in the RANK() method on a filtered set that matches the other rows tied with the current row. Since the RANK() call for the tiebreak will start at one you will need to subtract one to compensate.
The end result ends up looking like:
=RANK(U9, U$9:U$58, 1) + RANK(D9, FILTER(D$9:D$58, U$9:U$58=U9)) - 1

Resources