I have a teacher gradebook that uses category weighting (and evaluation weighting within each category). The formula I use to calculate final grade is found in column E here:
https://docs.google.com/spreadsheets/d/1TMsuJWtc4C7tebZGVVyeA4qbmLCnGZRi55ZRJsI-jGE/edit?usp=sharing
What I would like to do is give teachers an option to reduce the total marks for any particular student for an evaluation.
Example:
Evaluation total marks is 10, student mark is 4 (40%)
Teacher decides to make the total marks for this student = 5.
Teacher would enter: 4 [5] where 4 is the student mark and [5] is the new total marks for the evaluation. New percentage is 80%
I have written the formula to calculate the new percentage without issue however I cannot figure out how to get the final grade for this student.
In the linked spreadsheet above, student 1 and student 2 should have the same final grade in column E.
How can I change my formula in column E (starting at E8) to include cases like 4 [5]?
I believe the simplest solution would be to rewrite your formula in column E to use the numbers from the percentage column to calculate the grade, instead of using the complicated string you will find in the marks column.
Example formula that you could use in E8:
=IFERROR(SUMPRODUCT(FILTER(N8:Y8,ISFORMULA(N8:Y8))*FILTER(N$4:Y$4,ISNUMBER(N$4:Y$4))) *100 / SUM(N$4:Y$4),"")
Well that was fun! Using the recommendation of #TomSharpe I came up with this that seems to work:
=IF(ISBLANK($C8),"",IFERROR((
Settings!$E$3*(IF(COUNTIF($N$5:$HD$5,Settings!$D$3)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$3,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$3,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$4*(IF(COUNTIF($N$5:$HD$5,Settings!$D$4)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$4,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$4,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$5*(IF(COUNTIF($N$5:$HD$5,Settings!$D$5)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$5,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$5,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$6*(IF(COUNTIF($N$5:$HD$5,Settings!$D$6)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$6,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$6,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$7*(IF(COUNTIF($N$5:$HD$5,Settings!$D$7)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$7,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$7,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$8*(IF(COUNTIF($N$5:$HD$5,Settings!$D$8)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$8,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$8,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$9*(IF(COUNTIF($N$5:$HD$5,Settings!$D$9)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$9,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$9,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$10*(IF(COUNTIF($N$5:$HD$5,Settings!$D$10)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$10,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$10,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$11*(IF(COUNTIF($N$5:$HD$5,Settings!$D$11)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$11,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$11,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$12*(IF(COUNTIF($N$5:$HD$5,Settings!$D$12)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$12,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$12,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
)/(IF(COUNTIFS($N$5:$HE$5,Settings!$D$3,N8:HE8,"<>")>=1,Settings!$E$3,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$4,N8:HE8,"<>")>=1,Settings!$E$4,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$5,N8:HE8,"<>")>=1,Settings!$E$5,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$6,N8:HE8,"<>")>=1,Settings!$E$6,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$7,N8:HE8,"<>")>=1,Settings!$E$7,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$8,N8:HE8,"<>")>=1,Settings!$E$8,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$9,N8:HE8,"<>")>=1,Settings!$E$9,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$10,N8:HE8,"<>")>=1,Settings!$E$10,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$11,N8:HE8,"<>")>=1,Settings!$E$11,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$12,N8:HE8,"<>"
)>=1,Settings!$E$12,0)),"No Grade"))
Related
I'm looking for a solution for a problem I'm facing in Excel. This is my table simplified:
Every sale has an unique ID, but more people can have contributed to a sale. the column "name" and "share of sales(%)" show how many people have contributed and what their percentage was.
Sale_ID
Name
Share of sales(%)
1
Person A
100
2
Person B
100
3
Person A
30
3
Person C
70
Now I want to add a column to my table that shows the name of the person that has the highest share of sales percentage per Sales_ID. Like this:
Sale_ID
Name
Share of sales(%)
Highest sales
1
Person A
100
Person A
2
Person B
100
Person B
3
Person A
30
Person C
3
Person C
70
Person C
So when multiple people have contributed the new column shows only the one with the highest value.
I hope someone can help me, thanks in advance!
You can try this on cell D2:
=LET(maxSales, MAXIFS(C2:C5,A2:A5,A2:A5),
INDEX(B2:B5, XMATCH(A2:A5&maxSales,A2:A5&C2:C5)))
or just removing the LET since maxSales is used only one time:
=INDEX(B2:B5, XMATCH(A2:A5&MAXIFS(C2:C5,A2:A5,A2:A5),A2:A5&C2:C5))
On cell E2 I provided another solution via MAP/XLOOKUP:
=LET(maxSales, MAXIFS(C2:C5,A2:A5,A2:A5),
MAP(A2:A5, maxSales, LAMBDA(a,b, XLOOKUP(a&b, A2:A5&C2:C5, B2:B5))))
similarly without LET:
=MAP(A2:A5, MAXIFS(C2:C5,A2:A5,A2:A5),
LAMBDA(a,b, XLOOKUP(a&b, A2:A5&C2:C5, B2:B5)))
and here is the output:
Explanation
The trick here is to identify the max share of sales per each group and this can be done via MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...). The size and shape of the max_range and criteria_rangeN arguments must be the same.
MAXIFS(C2:C5,A2:A5,A2:A5)
it produces the following output:
maxSales
100
100
70
70
MAXIFS will provide an output of the same size as criteria1, so it returns for each row the corresponding maximum sales for each Sale_ID column value.
It is the array version equivalent to the following formula expanding it down:
MAXIFS($C$2:$C$5,$A$2:$A$5,A2)
INDEX/XMATCH Solution
Having the array with the maximum Shares of sales, we just need to identify the row position via XMATCH to return the corresponding B2:B5 cell via INDEX. We use concatenation (&) to consider more than one criteria to find as part of the XMATCH input arguments.
MAP/XLOOKUP Solution
We use MAP to find for each pair of values (a,b) per row, of the first two MAP input arguments where is the maximum value found for that group and returns the corresponding Name column value. In order to make a lookup based on an additional criteria we use concatenation (&) in XLOOKUP first two input arguments.
I made a small workbook that exactly mimics the original formulas I posted. The purpose of the workbook is to calculate the bonuses for each employee based on various inputted combinations (listed below). Here is how my workbook is laid out:
Data Tab
Bonus Tab
Base Bonus Tab
Summary Tab
Picture of the Data tab that I utilize to input the different combinations:
Data Tab
List of the combinations:
Employee % (cell B3) & Company % (cell B4) cells have numbers inputted = Combo 1 (range: 0%-100%)
Employee $ (cell B5) & Company $ (cell B6) cells have numbers inputted =Combo 2 (range: $0-no limit)
Base Salary (B2) is Yes & Employee % (cell B3) cells have been inputted = Combo 3 (Base Salary is either Yes or blank)
Base Salary (B2) is Yes & Job Title (A8) & Employee % (cell B8) cell have been inputted = Combo 5
I use cell C1 for an IF statement to dictate which formula to use based on the combinations above. (ex. numbers in B5 & B6 = 1)
=IF(AND($B$2<>"",$A$8<>"",$B$8<>""),5,IF(AND($B$2<>"",$B$3<>""),3,IF($B$3<>"",1,IF($B$5<>"",2))))
Picture of the Bonus Tab: Bonus Tab
Picture of the Base Bonus Tab: Base Bonus Tab
Picture of the Summary Tab: Summary Tab
I have created formulas for each combinations separately, but as soon as I try to combine them into one, I get the Too many arguments error message since combo 3 & combo 5 use false within the IF statement. I am attempting to avoid making a calculations table and would prefer utilizing one formula on the summary tab by employee in column B.
I will further explain combo 3 specifically - If the base bonus is less than the regular bonus, than multiply the base bonus * Employee % + Company&Vendor bonus * Company %. If base bonus is more than regular bonus, than multiply regular bonus * Employee % + Company&Vendor bonus * Company %.
Example:
Bobby
Base Bonus $50 < Regular Bonus $100
$50 * 50% employee % = $25
+ $200 company + $0 vendor * 50% company = $100
Final answer is $125 if base bonus if < regular bonus
I will further explain combo 5 specifically - If the base bonus is less than the regular bonus, than multiply the base bonus * employees job title Employee % + Company&Vendor bonus * job title Company %. If base bonus is more than regular bonus, than multiply regular bonus * employees job title Employee % + Company&Vendor bonus * job title Company %.
Example:
Bobby
Base Bonus $50 < Regular Bonus $100
Find Bobby's Job title to determine Employee % & Company %
75% Employee % for Officers and 50% Company %
75% * $50 + 50% * ($200 Company & $0 Vendor) = $137.5
Final answer is $137.5 of base bonus if < regular bonus
Here is list of each formula by combo:
Combo 1:
=IF(Data!$C$1=1,Data!$B$3*Bonus!D2+Data!$B$4*(Bonus!E2+Bonus!F2))
Combo 2:
=IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$6+Data!B5))
Combo 3:
=IF(Data!$C$1=3,IF(VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)<VLOOKUP(Summary!A2,Bonus!$A$2:$D$5,4,FALSE),VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)*Data!$B$3+Data!$B$4*(Bonus!E2+Bonus!F2),VLOOKUP(A2,Bonus!$A$2:$D$5,4,FALSE)*Data!$B$3+Data!$B$4*(Bonus!E2+Bonus!F2)))
Combo 5:
IF(Data!$C$1=5,IF(VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)<VLOOKUP(Summary!A2,Bonus!$A$2:$D$5,4,FALSE),VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,2,FALSE)+(Bonus!E2+Bonus!E2)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,3,FALSE),VLOOKUP(A2,Bonus!$A$2:$D$5,4,FALSE)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,2,FALSE)+(Bonus!E2+Bonus!E2)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,3,FALSE)))
Hopefully this is a lot more clear than my initial post and can easily be replicated. Let me know if you have any questions, Thank you!
I found some issues in your formulas
Combo3 In the else option you have A2 following the pattern it should be Summary!A2
Combo5 the sum is in the same cell you have (Bonus!E2+Bonus!E2) it should be (Bonus!E2+Bonus!F2)
I didn't record the initial nested If to compare why it is not working. I got this:
Final Nested:
=IF(Data!$C$1=1,Data!$B$3*Bonus!D2+Data!$B$4*(Bonus!E2+Bonus!F2),IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$6+Data!B5,IF(Data!$C$1=3,IF(VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)<VLOOKUP(Summary!A2,Bonus!$A$2:$D$5,4,FALSE),VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)*Data!$B$3+Data!$B$4*(Bonus!E2+Bonus!F2),VLOOKUP(Summary!A2,Bonus!$A$2:$D$5,4,FALSE)*Data!$B$3+Data!$B$4*(Bonus!E2+Bonus!F2)),IF(VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)<VLOOKUP(Summary!A2,Bonus!$A$2:$D$5,4,FALSE),VLOOKUP(Summary!A2,'Base Bonus'!$A$2:$B$5,2,FALSE)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,2,FALSE)+(Bonus!E2+Bonus!F2)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,3,FALSE),VLOOKUP(B2,Bonus!$A$2:$D$5,4,FALSE)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,2,FALSE)+(Bonus!E2+Bonus!F2)*VLOOKUP(VLOOKUP(Summary!A2,Data!$A$16:$B$19,2,FALSE),Data!$A$8:$C$11,3,FALSE)))))
I have this table in Excel:
I am trying to get weighted sum depending on two conditions:
Whether it is Company 1 or Company 2 (shares quantity differ)
Whether column A (Company 1) and column B (Company 2) has 0 or 1 (multipliers differ)
Example:
Lets calculate weighted sum for row 2:
Sum = 2 (multiplier 1) * 50 (1 share price) * 3 (shares quantity for Company 1) +
+0.5 (multiplier 0) * 50 (1 share price) * 6 (shares quantity for Company 2) = 450
So, Sum for Row 2 = 450.
For now I am checking only for multipliers (1 or 0) using this code:
=COUNTIF(A2:B2,0)*$B$9*$B$8 + COUNTIF(A2:B2,1)*$B$9*$B$7
But it does not take into account the shares quantities for Company 1 or Company 2. I only multiply 1 share price with multipliers, but not with shares quantity).
How can I also check whether it is Company 1 or Company 2 in order to multiply by corresponding Shares quantity?
Upd:
Rasmus0607 gave a solution when there are only two companies:
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Tom Sharpe gave a more general solution (number of companies can be greater than 2)
I uploaded my Excel file to DropBox:
Excel file
I can offer a more general way of doing it with the benefit of hindsight that you can apply to more than two columns by altering the second CHOOSE statement:-
=SUM(CHOOSE(2-A2:B2,$B$7,$B$8)*CHOOSE(COLUMN(A:B),$E$8,$E$9))*$B$9
Unfortunately it's an array formula that you have to enter with CtrlShiftEnter. But it's a moot point whether or not it would be better just to use one of the other answers with some repetition and keep it simple.
You could also try this:-
=SUMPRODUCT(N(OFFSET($B$6,2-A2:B2,0)),N(OFFSET($E$7,COLUMN(A:B),0)))*$B$9
Here's how it would be for three companies
=SUM(CHOOSE(2-A2:C2,$B$7,$B$8)*CHOOSE(COLUMN(A:C),$F$8,$F$9,$F$10))*$B$9
(array formula) or
=SUMPRODUCT(N(OFFSET($B$6,2-A2:C2,0)),N(OFFSET($F$7,COLUMN(A:C),0)))*$B$9
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Since in the COUNTIF function, you don't know beforehand, which company column contains a 0, or a 1, I would suggest a longer, but more systematic solution using IF:
=$B$9*$E$8*IF(A2=1;2;0,5)+$B$9*$E$9*IF(B2=1;2;0,5)
This is a bit less general, but should produce the result you expect in this case.
i am working on my database in excel...I need to rank the Scorers by considering 4 league scores.I want Ranking based on Scores of leagues with priority from 1 to 4 i.e. who scored most in league 1 would be 1st and if same score in league 1 then consider league 2 scores and so on...my table is as following-
please if u know help me for ranking for my table...
..........A............B...............C................D..................E..............F
======= ======= ======= ======= ================
1.......ID......Score 1......Score 2......Score 3......Score 4......Rank
2...... N01.... 12............... 4................. 3................ 18
3...... N02.... 15............... 4................. 6................ 13
4...... N03.... 12............... 5................. 4................ 11
5...... N04.... 12............... 4................. 3................ 3
6...... N05.... 15............... 5................. 5................ 8
7...... N06.... 16............... 3................. 2................ 3
8...... N07.... 12............... 4................. 5................ 12
9...... N08.... 10............... 5................. 4................ 9
10.....N09.... 13............... 6................. 4................ 17
11.....N10.... 10............... 5................. 4................ 5
For ranking based on 2 fields i have used these formulas:
intermidiate total in F2 to F11 -
=RANK(B2,B$2:B$11,0)+SUMPRODUCT((B2=B$2:B$11)*(C2
and The Rank in G2 -
=RANK(F2,F$2:F$11,1)
But I cannot do it for ranking based on 4 columns...Help plz
Of course the easiest way to do this is simply to do Data > Sort and do 4 levels of sorting (Score1, ..., Score4), but I kinda liked this question to see if I could do it with formulas - A fun challenge...
The nicest way I could think of doing it without VBA would be to add in a few helper columns.
To do this, put the following formulas in:
F2: =B2
G2: =F2 & " - " & SUM(IF(B2=B$2:B$11,IF(C2>=C$2:C$11,1,0)))
And enter G2 as an array formula using ctrl + shift + enter.
Then, drag G2 across till I2 and then, just fill Columns F:I down for your dataset.
Now, if you sort based upon column I, you will have the data ordered as you want it.
Of course, you could make it all in one large and ugly formula in one cell per row:
=B2& " - " & SUM(IF(B2=B$2:B$11,IF(C2>=C$2:C$11,1,0)))& " - " & SUM(IF(C2=C$2:C$11,IF(D2>=D$2:D$11,1,0)))& " - " & SUM(IF(D2=D$2:D$11,IF(E2>=E$2:E$11,1,0)))
but this seems to be a better solution IMHO.
Hope this does the trick!
EDIT:
In response to your comment below, to get the rank, you'll need 2 extra columns (boy, this is getting long :p)...
Put in the following:
J2: =SUMPRODUCT((I2>=$I$2:$I$11)+0)+1
K2: =RANK(J2,$J$2:$J$11,1)+COUNTIF($J$2:OFFSET(J2,0,0),J2)-1
This will give you the rank using non-numeric data.
Hope this fully satisfies your criteria, but it's pretty ugly for sure... Like I said, I enjoyed the challenge of this, but the better way would be to just create a VBA function that took care of this for you...
If you know that the scores will be bounded (e.g. always below 100) you can calculate a weighted score like
WEIGHTED_SCORE = (((SCORE1*100) + SCORE2)*100 + SCORE3)*100 + SCORE4
= SCORE1*100^3 + SCORE2*100^2 + SCORE3*100 + SCORE4
Then rank based on the weighted score
I'd like to accomplish the following task. There are three columns of data. Column A represents price, where the sum needs to be kept under $100,000. Column B represents a value. Column C represents a name tied to columns A & B.
Out of >100 rows of data, I need to find the highest 8 values in column B while keeping the sum of the prices in column A under $100,000. And then return the 8 names from column C.
Can this be accomplished?
EDIT:
I attempted the Solver solution w/ no luck. 200 rows looks to be the max w/ Solver, and that is what I'm using now. Here are the steps I've taken:
Create a column called rank RANK(B2,$B$2:$B$200) (used column D -- what is the purpose of this?)
Create a column called flag just put in zeroes (used column E)
Create 3 total cells total_price (=SUM(A2:A200)), total_value (=SUM(B2:B200)) and total_flag (=(E2:E200))
Use solver to minimize total_value (shouldn't this be maximize??)
Add constraints -Total_price<=100000 -Total_flag=8 -Flag cells are binary
Using Simplex LP, it simply changes the flags for the first 8 values. However, the total price for the first 8 values is >$100,000 ($140k). I've tried changing some options in the Solver Parameters as well as using different solving methods to no avail. I'd like to post an image of the parameter settings, but don't have enough "reputation".
EDIT #2:
The first 5 rows looks like this, price goes down to ~$6k at the bottom of the table.
Price Value Name Rank Flag
$22,538 42.81905675 Blow, Joe 1 0
$22,427 37.36240932 Doe, Jane 2 0
$17,158 34.12127693 Hall, Cliff 3 0
$16,625 33.97654031 Povich, John 4 0
$15,631 33.58212402 Cow, Holy 5 0
I'll give you the solver solution as a starting point. It involves the creation of some extra columns and total cells. Note solver is limited in the amount of cells it can handle but will work with 100 anyway.
Create a column called rank RANK(B2,$B$2:$B$100)
Create a column called flag just put in zeroes
Create 3 total cells total_price, total_value and total_flag
Use solver to minimize total_value
Add constraints
-Total_price<=100000
-Total_flag=8
-Flag cells are binary
This will flag the rows you want and you can grab the names however you want.