Get sum of 3 large values out of 4 in MS Excel - excel

I need to calculate the best 3 marks of class test assignment and get the sum of them in Excel. I am wondering what would be the formula for this. For the reference I have added an image below:
I want among (17, 1, 19, 20) I get (17, 19, 20) and the sum (17+19+20) = 56 put it in final marks column

Since you have only 4 items, it can be calculated like this
=SUM(B3:E3) - MIN(B3:E3)

You can use the LARGE() function to get the largest, second largest, third largest values and sum them all up.
=SUM(LARGE(B3:F3,1),LARGE(B3:F3,2),LARGE(B3:F3,3))

I use this to get best 4 out of 6:
=SUM(LARGE(N4:S4,{1,2,3,4}))
which for your three becomes:
=SUM(LARGE(B3:F3,{1,2,3}))
But I don't enter it as an array formula, works just fine dragged down as necessary.

Related

How do I create the IF Statement in Excel which can handle many conditions. My Example provided

As you can see in my picture.
There is a table to the right.
Cell D3 has the option to select 90.0, 95.0, 99.0, and 99.9
Cell D4 is a % value
Cell D5 I have: IF(AND(D3=90,3/D4<9),3,4) Obviously if the user selects 90 for D3, then I want to determine which 2 X choices either 3 or 4 from the table are used based on the value of Y which I get by the 3/D4. This statement is working 100% correct.
MY QUESTION, How do I add the other parts of the table to this same line of code for when D3 = 95, 99, and 99.9?
I try this: =IF(OR(AND(D3=90, 3/D4<9),3,4, IF(AND(D3=95,4/D4<16),4,5)))
Try
=CHOOSE(MATCH(D3,{90,95,99,99.9},0),
IF(3/D4>= 9, 4,IF(3/D4>= 5,3,NA())),
IF(3/D4>=16, 5,IF(3/D4>= 7,4,NA())),
IF(3/D4>=20, 7,IF(3/D4>= 7,6,IF(3/D4>=6,5,NA()))),
IF(3/D4>=32,10,IF(3/D4>=15,9,IF(3/D4>=9,8,IF(3/D4>=8,7,NA()))))
)
In this formula MATCH(D3,{90,95,99,99.9},0) will return 1, 2, 3, or 4. This is used by CHOOSE to select the login in one of the four lines below.
Each of the next four lines is a nested IF statements. The question as asked has integer thresholds for 3/D4 and is a little ambiguous about things that fall in the gaps: for example, how do you handle C=90 and 3/D4=8.5. I've made the decision/assumption that when 3/D4<9, return 3. If that's wrong (for instance you want to round 3/D4 to an integer) you can modify the formula accordingly.
I've also made the decision to return NA when 3/D4 is below the lowest threshold. You can modify the formula to change that behavior too.

Unable to SUM from COUNTIF

I have produced a set of data using a countif as exampled below:
=COUNTIFS(Matrix!$C6:$EZ6,"1",Matrix!$C$5:$EZ$5,"Attainment",Matrix!$C$3:$EZ$3,AD$3)
What this is doing is looking at a students grades against a subject and calculating the count of that grade. I have 5 grades, *, 1, 2, 3, 4, so I have 5 sets of calculated columns for each subject. What I am now trying to do is a weighted sum using the results of these countif's. * = 0, 1=1,2=2 etc, however students can get more than 1 grade per subject so I need to average these.
Student X got two 2 grades for biology and one 3 grade, I need to do (2x2/2) + (1x3/3) = 2.3
I have tried
=SUM((F4*0)+(AG4*1/AG4)+(BH4*2/BH4)+(CI4*3/CI4)+(DJ4*4/DJ4))
However, I get a divide by zero error as not all cells hold a value above zero.
Is there a way to create a formula that says if the cell value is greater than zero then do the calculations, but if not ignore. I can't do a nested if. So, if the sum of AG4*1/AG4 results in a number then add this, but if it produces a zero, do not and move on and do the same for the next calculation. I can't do a nested if as more than one calculation may return a positive value.
Your weighting formula seems wrong. You wrote '(2x2/2) + (1x3/3) = 2.3'. However, (2x2/2) + (1x3/3) returns 3.
Shouldn't it be (2x2) + (1x3) / (2+1) = 2.3 ?
Try using the following formula:
=(F4*0)+(AG4*1)+(BH4*2)+(CI4*3)+(DJ4*4) / SUM(F4,AG4,BH4,CI4,DJ4)
You can use wrap it in an IFERROR function to avoid errors for students with no grades

Converting a excel field from a % to a decimal in a new formula

I have 4 different values being generated on a spreadsheet in different cells:
A=88.45%
B=88.45%
C=1.69%
D=95.67%
I need to add these values up and divide it by 4 to get the difference from a possibility of 100%. So, the functions I've written are:
A= =SUM(1-(D6/C6))
B= =SUM(1-(F6/C6))
C= =SUM(I6/H6)
D= =SUM(1-(K6/C6))
However, if I just have a formula that adds those cells up while they are displaying as a % and then divide it by 4 it doesn't give me the intended number which I need. The only way I've figured out to give me the accurate result was to convert them into decimals, but I'm not sure how to exactly write that. If it's even possible. I still need them displaying as a % in the original cells is the issue.
A= 0.1155
B= 0.1155
C= 0.0169
D= 0.0433
Divide those by 4 and you get the correct 7.28%. Then I need to subtract that from 100% to generate the actual average of those 4 cells.
Any insight?
**EDIT* 2nd formula added
The proper formula to obtain your desired result of 7.28% from the four values in Row 34 (January) is:
=SUM(1-E34,1-G34,J34,1-L34)/4
OR
=1-AVERAGE(E34,G34,1-J34,L34)
where:
E34:= 88.45%
G34:= 88.45%
J34:= 1.69%
L34:= 95.67%
As an aside, the SUM function in each of those cells is entirely superfluous.
=1-D34/C34
will give the same result as
=SUM(1-(D34/C34))

IF Formula not calculating properly

I've structured a formula that should spit out a numerical answer that is basically a simple sum formula with IF statements assigning numerical values to qualitative inputs. Apologies for the length, I am looking at a number of different factors.Formula is:
Cell F36 contains:
=IF(F32="Medium-High", 18, IF(F32="High", 24, SUM(F16, IF(F20="High",5,IF(F20="Medium-High",4,IF(F20="Medium",3,IF(F20="Low-medium",2,IF(F20="Low",1))))),IF(F24="High",5,IF(F24="Medium-High",4,IF(F24="Medium",3,IF(F24="Low-Medium",2,IF(F24="Low",1))))),IF(F28="High",5,IF(F28="Medium-High",4,IF(F28="Medium",3,IF(F28="Low-Medium",2,IF(F28="Low",1,IF(F28="N/A",0)))))),IF(F30="N/A",0,IF(F30="High",5,IF(F30="Medium-High",4,IF(F30="Medium",3,IF(F30="Low-Medium",2,IF(F30="Low",1)))))),IF(F32="High",5,IF(F32="Medium-High",4,IF(F32="Medium",3,IF(F32="Low-Medium",2,IF(F32="Low",1,IF(F32="N/A",0)))))))))
F16 - contains values from 1 to 5
F20, F24, F28, F30, F32 - Are dropdowns, where you choose a value: Low, Low-Medium, Medium, Medium-High, High;
Right now, based on a test input, where: F16 = 5, F20 = Low (1), F24= Medium-High (4), F28 = N/A (0), F30 = Medium (3), F32 = Medium (3) my output in F36 is 11, however doing simple adding, I should be at 5+1+4+0+3+3 = 16.
Where am I losing 5 points?
You can create a table allocating numerical output to each qualitative inputs and using vlookup to get your output. For example, for a table created on K19:L25, the following can be used:
=SUM(F16,VLOOKUP(F20,K19:L25,2,FALSE),VLOOKUP(F24,K19:L25,2,FALSE),VLOOKUP(F28,K19:L25,2,FALSE),VLOOKUP(F30,K19:L25,2,FALSE),VLOOKUP(F32,K19:L25,2,FALSE))
EDIT:
Tried your formula and it gives the correct result. Maybe your 5 in F16 is not a numerical value? You can test it by using
=ISNUMBER(F16)
and it should give a TRUE if it is a number.
Debug embedded IFs is just hell.
What you are doing is recode a 5 levels scale. You may use alternative solutions.
a. place the 5 text values (from "Low" to "High") somewhere in a sheet, say in T1:T5, even better, give this range a name
then you can retrieve the values you search with
MATCH(F20,$T$1:$T$5,0)
b. if it's suitable for your use, you may use combo boxes, presenting the 5 choices and giving the desired answer (from 1 to 5) in a linked cell.
(maybe not the answer, but I can't comment…)
(This should be a comment but I needed the formatting capabilities of an answer)
This is the current logic of your formula:
Check cell F32: "Medium-High" outputs 18, "High" outputs 24
If F32 is neither of those, then SUM the following:
F16
Lookup for F20, F24, F28, F30, and F32 where the lookup for each is:
"High" = 5
"Medium-High" = 4
"Medium" = 3
"Low-Medium" = 2
"Low" = 1
I find it strange that you first check cell F32 only to check it again later in the sum. Because this current logic produces incorrect results, we can't really advise how to fix it without sample data and expected results. My guess is you are summing too many lookups by including the F32 in there, but that's just speculation without data.

Using a subset of excel entries for calculation

Assume that you have 5 cells with values:
[12, 23, 50, 89, 95]
and you are interested in finding the average of the four largest entries (that is drop 12 because it is the smallest).
I wonder how one can do that in excel?
You can get the average of the largest 4 from 5 with this formula
=AVERAGE(LARGE(A1:E1,{1,2,3,4}))
that will only average 4 values even if there are duplicates
Generically if you might have a variable number of values then to average without the smallest value you can use this version
=(SUM(Range)-MIN(Range))/(COUNT(Range)-1)
again that will work OK with duplicates - of course there must be at least 2 numbers in the range
You can use AVERAGEIF(range,condition)
So in your case, it will be AVERAGEIF(A1:E1,">"&MIN(A1:E1))
Hope this helps..
Use =LARGE to get the ǹ-th largest value then use =SUMIF to add if the value is larger than the n-th value!
In pseudocode something like this: =SUMIF(data >= LARGE(range, n))/n, sorry it's been a while since I used excel. `

Resources