Sum values based on date compared to current date - excel

I am currently trying to create an if statement that sums values based on whether a date has passed.
Excel example image
M1 to M12 dictate the months of the year e.g. 01/01/2021 for M1 and 01/12/2021 for M12
Now I want to create or use a formula that sums the values in row 4 based on what month we are currently in --> If we are currently in M1, e.g. 15/01/2021, then it only needs to sum the value in A4. However, if we are, for example, in M3 (28/03/2021) then it needs to sum A4 + B4 + C4
I tried using the following formula but the problem is that when it finds a value larger than 01/01/2021 it doesn't take other months into consideration anymore
=IF(TODAY()>=A2;A4;IF(TODAY()>=B2;SUM(A4:B4);0))
I added the zero at the end of the function to close the formula but my idea was to prolong it up til 12 months. However, it only ever sums the first cell (A4) because conditions have already been met. How do I 'overwrite' the first condition if more months have passed?
Any help would be greatly appreciated; I excuse myself for asking potentially dumb questions but Excel isn't my strong point and I am trying to learn.
Kind regards,
VHes

Try:
=SUM(INDEX(4:4,SEQUENCE(MONTH(TODAY()))))

An alternative approach using SUMIF:
=SUMIF(A2:L2,"<"&EOMONTH(TODAY(),0),A4:L4)
If SEQUENCE is not supported by your version of excel, (based on comments it does), you could also try the following:
=SUM(A4:INDEX(A4:L4,MONTH(TODAY())))
The trick here is that INDEX actually supplies a cell address, and displays the contents of that cell when needed.

Related

Use VLOOKUP as criteria inside COUNTIFS

After years of using this community, I have a question that I can't find an answer to. I hope you all can help!
I am trying to get a count of the number of "Grounded" items that each individual is overdue for. My screenshot (Count Tracker) shows a very condensed version of what I'm working with. Columns A-C is my large (15,000 rows) data field that is imported from an external source. In columns G-H I have listed each possible task (about 100 rows) and the type (Grounded and Non-Grounding plus many others). Column F is where I am trying to get the count.
My formula in F9 currently uses COUNTIFS to get a count of the instances in the large array that equal E9 ("Smith" in this case) and where the due date in the large array is less than or equal to the current date in F8. What I can't figure out is how to also add to count the Tasks in the large array where the task type in Column H equals "Grounded". I tried VLOOKUP, but it seems it doesn't like it and tells me there is a problem with the formula. It doesn't work, but here's the general idea of what I'm after:
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,VLOOKUP($B$2:$B$7,$G$2:$H$4,2,FALSE),"=Grounded")
With how the data is currently presented, Smith should have a count of 1 and Jones should have a count of 0. I have a feeling that this is more simple than I'm making it to be, but I can't figure it out. I am using Excel 2016.
Hopefully I explained the problem well enough. Thank you for your assistance.
With Excel 2016 I'd say MMULT() is a good alternative here:
CSE-Formula in F9:
=SUM((A$2:A$7=E9)*(MMULT((TRANSPOSE(G$2:G$4)=B$2:B$7)*(TRANSPOSE(H$2:H$4)="Grounding"),ROW(G$2:G$4)^0))*(C$2:C$7<=F$8))
You could add a fourth column that stores whether that Task is Grounded
The formula for D2 would then be:
=INDEX($H$2:$H$4,MATCH(B2,$G$2:$G$4,0))
Modify your CountIfs formula to use this new column as a criteria
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,$D$2:$D$7, "Grounded")
Try this Sumproduct+Vlookup formula without helper solution, and can work for your Excel 2016
In F9, formula copied down :
=SUMPRODUCT((A$2:A$7=E9)*(VLOOKUP(T(IF({1},$B$2:$B$7)),G$2:H$4,2,0)="Grounded")*($C$2:$C$7<=$F$8))

time sheet overtime hours add up

This is basically about overtime calculations, but I want it calculated separately. IF(A1>8,A1-8,0)
I want A1 when it reaches 8, to flow over to I1. Now I know this formula...
But additionally I would also like B1, C1, and D1 to do the same. So what I'm saying is that each of those cells when a value above 8 is input, I would like it to flow into I1 aswell. That's one part of it, also I would like any amount that is input to cells E1, F1, and G1 to flow into I1 . The final 3 cells are basically weekend work and considered by my company as overtime.
=SUMPRODUCT((A11:G11>H3:N3)*(A11:G11-H3:N3))
So this one works guys but, what I want to do is grab from two separate rows for the seven days of the week. Like this.....
=SUMPRODUCT((D11:G11,A13:C13>H3:N3)*(D11:G11,A13:C13-H3:N3))
But what I'm getting now is #VALUE! I'm not sure what I'm doing wrong.
I would like to know if this is possible and will greatly appreciate the help solving this problem.
So Seeming no one answered you guys decided to minus my rep, I stumbled on the answer myself. I worked this out by making a table with each day and the hours of single time in them.
For the purpose of this formula below I'll say K3 is Sunday and that D19 is also the hours worked on the Sunday. It tells the cell to compare the number input to D19 and if greater than, then minus what is in K3 and return the value in the cell I have input the formula. Because this is for overtime I wanted it to add up each day separately and give me a running total through the week. This Formula worked perfectly for me.
=SUM((D19>$K$3)(D19-$K$3),(O11>$L$3)(O11-$L$3),(P11>$M$3)(P11-$M$3),(Q11>$N$3)(Q11-$N$3),(K13>$H$3)(K13-$H$3),(L13>$I$3)(L13-$I$3),(M13>$J$3)*(M13-$J$3))
Feel free to copy and paste and change it to suit your needs.

Using the 'TODAY' function

My spreadsheet is to show me how many days active a certain field has been.
For this I am trying to find a formula which will automatically take the entered date from one cell and deduct it from "todays" date.
As an example I have used =DATEVALUE("22/04/2017")-TODAY() - and although this works, i am unable to drag the formula down into other cells, to auto populate when a date has been entered/ amended. I'm having to enter the formula above every time, and if the date changes, as an example from the 22/04/2017 to the 20/04/2017, I would have to manually amend the formula too. How can I get it just pick up the date in that particular cell and deduct "today" from it?
Sorry if i'm rambling, I just don't know if I'm explaining myself properly.
Thank you
Typically, 'how many days active a certain field has been' would be a positive number (i.e. the number of days). Reverse the subtrahend and minuend to get a positive integer like this,
=today()-a3
To avoid getting 5/15/2017 or 42,870 as the result when A3 is blank, check to see if there is something in A3 before attempting subtraction.
=if(len(a3), today()-a3, text(,))

Excel: Need to sum the lowest 5 values from a column of 10

Trying to build an Excel formula that will sum the 5 lowest golf scores out of 10. Currently using a table setup, provided by another forum, but it's not quite getting me there, as I think it's ignoring duplicates. The letter 'E' should also be equal to the value of zero.
Screen shot: http://imgur.com/G8xoul9
Here are the formulae in use, identified by cell:
G17: =SUM(IF(G5:G14<=G25,G5:G14)/COUNTIF(G5:G14,G5:G14))
G21: =MIN(G5:G14)
G22: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G21)+1)
G23: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G22)+1)
G24: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G23)+1)
G25: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G24)+1)
The result in G17 should be -7, but I'm not getting there just yet. Your generous help will be greatly appreciated. Thank you!
Try this, entered as an array formula (CTRL-ENTER):
=SUM(SMALL(scores,{1,2,3,4,5}))
where scores is the range of cells with your scores
Update for Google Sheets
This can also work in Google Sheets, but it seems like it requires an ArrayFormula. You enter the above with CTRL-SHIFT-ENTER or manually type the array formula:
=ArrayFormula(SUM(SMALL(scores,{1,2,3,4,5})))
You have made this more confusing than it needs to be.
Assume your golf scores are in any number of rows in column A. In column B, we want to pick up the 5 lowest scores. This can be written as follows, starting with B1 and copied down for as many low places you want to check:
=Small(A:A,row())
row() returns the current row that the formula is on (to start with, row 1, with B1).
Then on cell C1, simply sum these results, and that's all you need:
=SUM(B:B)

Conditional IF Statement in Excel, Change Other Cells According to Content

I'm trying to make a revision timetable for myself on Excel.
Let's say I'm doing four exams, A to D. Each exam has a certain number of "practice papers" that I have to do. Below is a demonstration table on Excel:
ExamName NoOfPapers
ExamA 4
ExamB 5
ExamC 7
ExamD 1
There is another table, with two columns: MonthDate and the paper I want to practice on that da. So,
May Paper?
1
2
.
.
.
29
I want to make it work so that if I put ExamA in the field under Paper?, it would automatically deduct 1 from the NoOfPapers of ExamA, to make it 3, so I make sure I'm not repeating the paper too many times.
If I only had 17 papers, it would have been easy to do it manually. But unfortunately I have 99 papers to do (exactly 99 :P).
How can I implement this on a cell as an IF statement (or any other possible way) on Microsoft Office Excel?
Thank you! :)
change the title of the column "NoOfPapers" to "OriginalNoOfPapers". Then create a column next to it called "NoOfPapersRemaining".
Assuming the cell with "ExamName" is A1, use the following formula in C2: =B2 - COUNTIF(Z:Z, A2)
(this also assumes that the column called "Paper?" is in column Z... in real life change it to the correct column on your spreadsheet.
I made four columns in row 1, Exam Name, Exam Total, Completed,Remaining. The completed column has the function
=Countif(B:B,A:A)
in roww 2, 3, 4, 5. The remaining columns are
D2="SUM(B2-C2)"
D3="SUM(B3,C3)"
D4="SUM(D4,C4)"
D5="SUM(D5,C5)"
In row 7 I have three columns, Date Complete, Exam Name, Paper. Exam Name must = The exact same as Cell A2:A5. All you would need is to enter the date and the exam name and it will show the total papers done and the remaining.
This can be better but does what I believe you asked. For instance, use of conditional formatting. If there is a deadline, add a column for the date and use conditional formatting to display an approaching deadline. Freeze row 7 to see remaining after entering a lot of dates in cell A8.
Hope this helps. I'm not a pro but like learning more about Excel.

Resources