Stackoverflow has been really helpful on my Nested IF confusions! I thought I'd ask one more question to help solve my seemingly complete lack of understanding the logic flow in Nested If's.
Current formula used in Cell (P3) is =IF(ISBLANK(M3),TODAY()-L3,M3-L3)
It works just fine, except for then there is no data in Start Date (L3) and Finish Date (M3). When both cells are Blank it shows the number 43,091.The logic that I need however is as follows.
If both start date (L3) and Finish Date (M3) are BLANK, Result an Empty Cell (P3).
If Start Date (L3) has a date, and Finish Date (M3) is BLANK, Count the number of days between Start Date (L3) and TODAY.
If Start Date (L3) and Finish Date (M3) both have Dates, count the number of days between Start Date (L3) and Finish Date (M3).
I hate to be a pest but i just cannot wrap my head around it and have struggled with this for probably 2 hours now. ANY Help is appreciated everyone! Thank you so much.
James
Add the test:
=IF(L3="","",IF(M3="",TODAY()-L3,M3-L3))
Related
here's my problem:
We have an Excel sheet at work in order to manage various tasks all set on individually specified timelines - we're talking hundreds of tasks per month with dates that are currently all being maintained manually.
Let's say we have Task A and that task has a Due Date. That Task is split into several subtasks, all with their individual due dates. Date 1 would then always be Due Date - 10 days, Date 2 would be Due Date - 20 days, Date 3 would be Due Date - 17 days and so on. This then creates a neat timeline of when everything needs to be done.
That in itself would be easy enough, problem is that all of these subtasks have to be done on a specific workday as well. Meaning that subtask 1 would not only have to be done Due Date - 10 days, but it would also have to fall on a Monday - if for whatever reason Due Date - 10 would happen to fall on like a Wednesday, it would have to subtract another 2 days. And then the real problem is that Date 2 and 3 each have to fall on different workdays and Task B has an entirely different schedule again.
Now, the first thing that came to my mind was attempting to just nest a couple IFs - and I've even managed to come up with a working formula for that. Problem here is that it's so stupidly long and (thanks Excel) utterly unreadable - if for some reason someone else had to change something about it or troubleshoot the entire file 1-2 years from now, they'd probably have to spend at least an hour reconstruct how the hell any of it actually worked. Which doesn't sound particularly appealing to us.
Here's a screenshot to help illustrating the situation:
And here's a draft of the current formula that I'm really not happy with, despite it somewhat doing the job:
=IF(AND(WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11)>5,VLOOKUP(B2,Table1,5,FALSE)=0),(K2-VLOOKUP(B2,Table1,3,FALSE))-(WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11)-5), IF(VLOOKUP(B2,Table1,5,FALSE)=0,K2-VLOOKUP(B2,Table1,3,FALSE), IF(WEEKDAY((K2-VLOOKUP(B2,Table1,3,FALSE)),11)=0,K2-VLOOKUP(B2,Table1,3,FALSE), (VLOOKUP(B2,Table1,5,FALSE)-WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11))+K2-VLOOKUP(B2,Table1,3,FALSE))))
My question is now: Does anyone have an idea how to solve this in a less confusing and unclear manner? I was trying to get something done using =CHOOSE() but ultimately ended up with the same problem of eventually having to resort to 7 IFs and dozens of LOOKUPs, making the final formula just as long. I wouldn't be disinclined towards some kind of helper table that asigns the last 7 days and their workdays to every single day of the year... but I don't think tossing another 20,000 calculated cells into a file that already has tens of thousands other calculated cells would really be a serviceable alternative... or make the situation any less obscure at all tbh.
So, anyone any idea how to go about this? Or is there really no realistic alternative than to use a bunch of IFs?
Edit: Forgot to mention that 1 special case:
There's also the situation when a date doesn't have to fall on a specific workday - in which case it's simply due date - X days. The problem here is that in those cases the dates could fall on a weekend, so the formula would have to move these dates to the previous Friday as well.
Assume you have some date and you want to "back up" ten days and then to the preceding Monday, unless the resultant date is a Monday. The general formula would be something like:
=A2-10+1-WEEKDAY(A2-10-DOW)
Where DOW translates into
Sunday=0
Monday=1
Tuesday=2
...
You should be able to modify your formulas to use this algorithm for day of the week.
If the two tables are named thisTable and keyTable, the following 365 formula is one way of implementing:
If your tables are as below, you can enter the formula in B2 and fill down and across. The references should self-adjust and return the proper dates.
Note that in keyTable, I enter the day of the week DOW as defined above, and not the textual date.
=LET(dys,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2,FALSE),
dow,VLOOKUP(thisTable[#[Task]:{Task]],KeyTable,COLUMNS($A:A)*2+1,FALSE),
due,thisTable[#[DueDate]:[DueDate]],
IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+1-WEEKDAY(due-dys-dow)))
If you want to have the result be the closest workday, instead of the preceding workday, then you need to add two clauses to the LET function
Calculate the subsequent workday date
Then use an IF to return the closest one to the original target
eg:
=LET(dys,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2,FALSE),
dow,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2+1,FALSE),
due,thisTable[#[DueDate]:[DueDate]],
dayPrev,IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+1-WEEKDAY(due-dys-dow)),
daySubseq,IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+7-WEEKDAY(due-dys-1-dow)),
IF((daySubseq-due+dys)>3,dayPrev,daySubseq))
The problem that I'm facing currently is I have a start date and end date for multiple different items. What I want to do is be able to see when a report would be due at each given month that it's accounted for with a end report (+14 days from end date). For example:
The Lookup tab that I have for reference of the dates above to be able to match the months looks like this:
Now I'm having trouble creating a formula that would actually work with this. If I'm thinking correctly it would be something like,
IF Start Date != Start Month then IF Start Date is between March Dates, "Report", . . . IF End Date hits, add 14 days, then "End Report" on given month after 14 days.
So for the example above the outcome would look like the following:
This is the end result that I would want in the end. Due note that August for Battlefield 5 is supposed to be blank due to the game ending on 8/19/2018, +14 days for a end report: 9/2/2018 is the End Report date so their would not be a Report in August for that given scenario. (I think this is possible but not 100% sure for the August scenario)
I am open to any kind of formulas/Arrays/VBA's that would accomplish this task. I'm just having difficulty coming up with a solution for this that has been bugging me for a while, so any help is much appreciated!!
If anything needs to be further explained please let me know and I will do my best as an edit to this post.
-Maykid
Based on what you explained, you could just have a simple formula as such (no need for VBA):
LOCALISATION OF THIS FORMULA (E2) UNDER FEBRUARY 2018 in the picture attached
=IF(AND(MONTH($C2)=MONTH(E$1),MONTH($C2+14)=MONTH(F$1)),"",IF(AND(MONTH($C2+14)=MONTH(E$1),YEAR($C2+14)=YEAR(E$1)),"End Report",IF(AND($B2<E$1,($C2+14)>E$1),"Report","")))
And then you can drag this formula.
I hope it helps.
BR
I have a sample data here that I want to get the days delayed.
As you can see,
The data shows the records for those users who did not submit their project, users who submitted on-time, and users who actually dont submit their project.
Currently,
I have this formula
=DATEDIF(A2,B2,"d")
for the first row to calculate the days delayed of first row.
Can I add in this formula that detects if the user dont submit their project and the delayed days continues counting for day delayed? Like for example the data on row 4. The column submitted_project is blank means the user still dont submit their project the days delayed will start counting after the deadline.
You don't need DateDif for that. (By the way it's Date-Dif for "date difference", not Dated-If)
You can simply subtract the two dates from each other and format the result as a number.
DateDif expects the earlier date as the first parameter, that's why it errors when the first parameter is the later date, i.e. when the project was submitted before the due date.
But with simple subtraction like =B2-A2 you can get the correct result. Better even, to check that both cells have dates before doing the calculation, to avoid misleading results, so
=if(count(A2:B2)=2,B2-A2,"")
Edit after comment: Yes.
=IF(COUNT(A5:B5)=2,B5-A5,IF(B5="",TODAY()-A5))
As requested, I have included a simplified screenshot that illustrates the issue.
As you can see, I subtracted the two dates and formatted it as "h:mm:ss". Why doesn't this give you the total amount of hours that have passed between the two dates? Is there a better way to do this? There is a great answer below, but I am trying to figure out why doing the way illustrated in this screenshot doesn't work.
END OF EDIT
I am aware that similar questions have been answered here, but for whatever reason this is not working for me at all.
I have two columns: one is a date, one is the time.
As you can see from the currently highlighted cell, the "time" column is actually stored as date with the time included. In column H, I have the date stored as a serial code so that the decimal number refers to a month, day, year, hour, minute, and second. When I subtract the serial code that refers to 2/16/2016 3:20:01 PM from the serial code that refers to refers to 2/14/2016 1:20:01 PM and format that cell as "h:mm", I am getting 2:00. Why?????
I have been hacking away at this for a while and this is supposed to be stupid easy and it's not working. Any help is greatly appreciated so I can move on to more important things.
It does work. Just take the difference between the two dates, format the cell containing the difference as Number, and then use one of the following formulas to get the units you want. I will assume that:
A1 has the value 2/16/2016 3:20:01 PM
B1 has the value 2/14/2016 1:20:01 PM
Into C1 enter A1 - B1, and format it as Number
If you want the difference as days, leave C1 as is.
If you want hours, use =24*(A1 - B1)
If you want minutes, use =24*60*(A1 - B1)
If you want seconds, use =24*60*60*(A1 - B1)
THE ANSWER TO THIS IS REALLY SILLY.
Below, you will find that Tim Biegeleisen provided an excellent answer to this question. I just wanted to further elaborate.
Sometimes having too many option for formatting can be a problem, which is what happened here.
When you subtract 2/14/2016 1:20:01 PM from 2/16/2016 3:20:01 PM and format it as h:mm:ss it only subtracts the hours portion and ignores days. You just have to somehow know that if you are trying to do what I'm trying to do, you have to format it as [h]:mm:ss and then it will calculate the total number of hours passed. The bracket around the "h" is the important part here. I hope this helps the next person who comes across this.
I have a worksheet that has a start date and end date. I need to get the number of months between these dates. I used the formula =MONTH(B1)-MONTH(A1) to get that #. However this formula fails when my dates span multiple years - if start date is 1/1/2014 and end date is 1/1/2015, then it returns a "1", when I'd like to get a "12".
I then tried DATEDIF(A1,B1,"m") to get the # of months between the dates, and that worked. My issue, however, can be summarized by the following example:
Situation 1:
Start Date: 1/5/2014
End Date: 3/1/2014
"MonthDif": 2
DateDif: 1
Situation 2:
Start Date: 1/5/2014
End Date: 3/10/2014
"MonthDif": 2
DateDif: 2
As you can see, the DATEDIF function returns the # of complete months, while my month - month function returns the number of months "occupied" by the difference between the start and end dates, regardless if they are complete months.
I need the number of months, regardless if full months, over any date period! Basically, I need exactly what the MONTH(B1)-MONTH(A1) returns, except it will work over multiple years.
Also, I was considering designing a custom VBA function to achieve the above. If anyone has any suggestions there.
If you use DATEDIF but always count from the 1st of the first month you'll get what you need, e.g. if you use =A1-DAY(A1)+1 that will give you the first of the A1 month, so use that in DATEDIF like this
=DATEDIF(A1-DAY(A1)+1,B1,"m")
Assuming B1 contains your end date and A1 contains your start date,
=IF(DAY(B1)>=DAY(A1),0,-1)+(YEAR(B1)-YEAR(A1))
*12+MONTH(B1)-MONTH(A1)
I need exactly what the MONTH(B1)-MONTH(A1) returns, except it will work over multiple years.
Ok, well, at the risk of stating the obvious:
=MONTH(B1)-MONTH(A1) + 12*(YEAR(B1)-YEAR(A1))
Rationale: a year is composed of twelve months.