I have a Google Sheet that has quiz entries. Each correct answer adds points and points will be deducted for wrong answer.
Here I use ARRAYFORMULA(SUMPRODUCT) formula to calculate points. The formula works fine to add points if answer is correct, but I want to deduct points for each wrong answer as an else condition.
My Spreadsheet
In above sheet, I want to deduct -5 point from Q3 for the wrong answer in N3 and calculate the points in O3.
How can I achieve this? How can I add if, else condition to this formula?
O3:
=ARRAYFORMULA(MMULT(IF(L3:N5=L1:N1,TRANSPOSE(P3:P5),TRANSPOSE(Q3:Q5)),TRANSPOSE(COLUMN(L1:N1))^0))
IF to get correct score
MMULT to add corresponding scores
If what you have is working for you, just add another set of sumproduct conditions to the formula already there
=... + ARRAYFORMULA(SUMPRODUCT((L3<>L1)*Q3 + ...)))
In an unused column to the right, put this formula into the third row.
=max(0, arrayformula(SUM(if(L3:N3=L$1:N$1, P3, Q3))))
'if Georges score can be negative then,
=arrayformula(SUM(if(L3:N3=L$1:N$1, P3, Q3)))
Double click the 'fill handle' (tiny square in the bottom-right of the selected cell) to fill down.
Related
I'm looking to return the start and end dates of a person availability based upon a gantt chart of their hours on a project.
I can at the minute only return the start of their availability, essentially my formula is looking left to right and returning the date of the first "0" cell it meets.
I need the formula to look right to left and return the date of the cell of the last "0" it meets.
Formula currently is:
=IFERROR(OFFSET(B3,(ROW(B3)-2)*-1,MATCH(0,C3:O3,0)),"")
This formula will return the results you're after:
{=INDEX($C$2:$S4,1,MAX(IF($C4:$S4>0,COLUMN($C4:$S4),0)))}
Enter as an array/CSE formula (use Ctrl+Shift+Enter to complete the formula - this will put the curly brackets in).
NB: It will return 00/01/1900 if the last date is greater than 0.
Adding this custom format to the result cells will hide the 00/01/1900: dd/mm/yyyy;;;
I used this to reference to get the answer:
http://www.mrexcel.com/forum/excel-questions/234469-find-last-value-row-greater-than-zero.html
I found the answer by using the formula above and the link provided. My data set was different to the sample one shown. Hence the cell references are different.
=(OFFSET(A3,(ROW(A3)-2)*-1,LOOKUP(9.999999999999E+307,IF(AA3:CP3>0,COLUMN(AA3:CP3)))))
I have the following formula in a cell:
=IF(Q12,ROUND(SUM(Q12:Q18)/7,2),"")
Now when I drag it down I want it to calculate SUM for Range Q19:Q25 i.e it should be;
=IF(Q19,ROUND(SUM(Q19:Q25)/7,2),"")
I believe OFFSET is the function to add in the formula but I am not sure how to do it.
You are correct, OFFSET will do this job nicely, but in writing your answer, I have had to make a consideration to the fact that I don't know what offset your formula is to the sum range!
This will do the job, and if your formula isnt in row 1, you'll need the change both of the row() - 1 statements to offset the formula back to 0 (i.e. if this formula starts in row 12, change row() - 1 to row() - 12
=IF(OFFSET($Q$12,(ROW()-1)*7,0),ROUND(SUM(OFFSET($Q$12:$Q$18,(ROW()-1)*7,0))/7,2),"")
Having said all of that, you have a conditional (=If(Q12) and a sum pointing to the same place, shouldn't you be checking Q12 for some truth, then summing?
I don't know what your data set is though, so I could be talking rubbish.
Hope this helps!
Taking only the SUM part of your formula and assuming placed in Row1 please try:
=SUM(OFFSET(Q$12,7*(ROW()-1),,7,1))
I would like to create a formula that sums all the values that I'm going to add in the future in some cells of the same row. For example, I would like to add cells D3,G3,J3,M3 and so on (separated 3 rows) in cell D1.
Best regards,
A good solution will depend on what (if anything) is in the intervening columns on row 3. A SUMPRODUCT function can produce some nice results by checking the stagger or offset of the columns but it isn't going to like text put into the intervening cells.
=SUMPRODUCT((INDEX(3:3, 1, 4):INDEX(3:3, 1, MATCH(1E+99,3:3 )))*NOT(MOD(COLUMN(INDEX(3:3, 1, 4):INDEX(3:3, 1, MATCH(1E+99,3:3 )))-1, 3)))
By switching to an array formula and a condition SUM function, you should be able to happily skip over any text values.
=SUM(IF(NOT(MOD(COLUMN(INDEX(3:3,1,4):INDEX(3:3,1,MATCH(E1+99,3:3)))-1,3)),INDEX(3:3,1,4):INDEX(3:3,1,MATCH(E1+99,3:3))))
Array formulas need to be finalized with Ctrl+Shift+Enter↵.
If neither ot those fits the bill, provide a little more information on the nature of what not to sum and more help can be offered.
This will do the job:
1) put =SUM(D2:XFD2) in cell D1
2) put =IF(MOD(COLUMN(D3)+2,3)=0,IF(D3="","",D3),"") in all cells from (D2 .. til the end)
3) put your data in D3 .... til the end.
Anonymous' solution works if you only need to sum one row. If you need to be able to drag that formula down, consider using a flag in row 2 to identify every 3rd column (like Anonymous did) , and use a sumif formula to add the columns where that flag is present.
Type
=
in the cell where your first result will appear (e.g. D1).
Click on the first value in the first row.
Press + on numpad.
Click on the next value in the next row.
Repeat steps 4-5 until you reach the last row.
Press Enter.
You can now select the results-cell (e.g. D1) and click and drag the small button to your lower right, across all the columns.
If you have a static reference - a constant in a cell that you do not wish to move use the $ operator, for example: $C$3 will not move column-wise or row-wise. $C3 can move column-wise but not row-wise and the opposite is true for C$3. This can be achieved in the Formula Bar, where you can also manually type in the function.
I have a spreadsheet that has columns for dates and the values can be either "1v, .5v, 1p, .5p, 1s, .5s"
I have 3 columns in each row one for each letter "v, p and s". I want to be able to add the total of all cells in the range grouped by letter and then display the sum for each letter in it's respective column (v, p or c).
Here is an example of the sheet:
Name Vacation Personal Sick 1/5/15 1/6/15 1/7/15 1/8/15
Billy 1.5 1 0 .5v 1v 1p
It is the formula that goes in the vacation/personal/sick cell that I just can't figure out.
I went down the array formula route and came up with essentially the same formula as #Sancho.s :-
=SUM(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"))
You could modify it to take account of blanks:-
=SUM(IF($E2:$H2<>"",LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v")))
Perhaps this would be better, to ignore any mis-formatted cells:-
=SUM(IFERROR(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"),0))
These all have to be put in with Ctrl-Shift-Enter.
Assuming the range you posted starts at A1, use
=SUMPRODUCT((RIGHT($E2:$G2,1)="v")*LEFT($E2:$G2,LEN($E2:$G2)-1))
in B2. Change "v" and the range to use suitably.
Pro:
It is not an array formula. See why this may be important
Con:
I could not make it work with blank cells.
This "array entered" version will also allow blanks
=SUM(IF(RIGHT(E2:G2)="v",SUBSTITUTE(E2:G2,"v","")+0))
confirmed with CTRL+SHIFT+ENTER
I am trying to use vlookup to return information based on the maximum value of a cell within a range.
I have a table in which each row is a sports team and each column is a weekly points total.
I have 2 cells that show the highest points scored in the current week and the name of the team that scored them.
The team name is generated by the formula
=VLOOKUP(MAX(Admin!G3:G16),Admin!G3:K16, 5, FALSE)
This works fine.
I also wish to have 2 cells that show the highest weekly points total ever achieved, along with the name of the relevant team.
However, I can not amend the above formula to work on a range instead of a row, and no matter what I do, it always returns an #N/A result for the team name.
The most logical formula I tried is
=VLOOKUP(MAX(Admin!N18:BE31),Admin!N18:BG31, 47, FALSE)
where columns N through BE are the weekly scores (which are generated by a formula, if that makes a difference?) and column BG contains the team names.
Maybe this function isn't designed to work on a range in the same way as a column, maybe I have made an error in the formula, or maybe there is another better way to retrieve the information?
I just can't work it out, so am sincerely hoping somebody can point me in the right direction.
Many thanks for any assistance.
Indeed, the vlookup function works only with columns. So does the match function. You need here to use a formula array (hit "Ctrl + Shift + Enter" once you've typed the function instead of the usual "Enter").
I came to the following function
=INDEX($A$2:$A$9,SMALL(IF($B$2:$D$9=$H$2,MATCH($A$2:$A$9,$A$2:$A$9,0),""),1))
with :
1) $A$2:$A$9 = The teams
2) $B$2:$D$9 = The weekly scores
3) $H$2 = the maximal score ever achieved
You just need to adapt the ranges and hit "Ctrl + Shift + Enter"
PS: If 2 teams achieved this score, then only the first one will show