I've been working on this most of the day and I'm stumped on this one part.
Here's some background: I've been asked to an injury log (which is created in Excel) and create a report around it (which I've been told has to be in Excel). Right now, I'm trying to count the number of injuries, that meet certain conditions, within the last three months.
This is what I got working so far:
=COUNTIFS('All Injuries'!C:C,"*S/R*",'All Injuries'!K:K,"*Yes*",'All Injuries'!M:M,">="&TODAY()-180,'All Injuries'!M:M,"<="&TODAY())
The issue that I'm running into is I can't depend on the TODAY function. There's a cell - A2 - that will have a date in it (12/15/2015, 11/15/2015, 10/15/2015, etc.)
What I want is to count the number of injuries that fall within that range (A2 to A2 minues 180 days). However, when I replace &TODAY, with A2, the formula just errors out.
So, that's where I'm stuck.
replace
&TODAY
with
&A2
Related
I'm trying to put together an excel spreadsheet to show the day-by-day impact of stays by 3rd country citizens in the EU's Schengen area (it's a fairly complex rolling 180 day window). At the moment, I have a column with every day from a start date (so lots of rows) and another where I enter a 1 if there was a stay in a Schengen country for that day. Then other columns calculate when the 180 day period started and how many days have been in Schengen for that day.
It's a bit of a faff having to enter a 1 for every day away. I'd like to have another worksheet where I simply enter the start and end dates of (an arbitrary number of) each stay and then the calculation spreadsheet simply works out if each date falls within a stay or not. Working out whether a date falls within one date range is pretty straightforward, but working out if it falls within several date ranges isn't obvious to me. Any suggestions please?
After a very fair comment, here's a couple of images that hopefully illustrate what I'm trying to do (please ignore the colours).
Example of date ranges, but the number of these should be arbitrary:
The calculated sheet - currently I have to enter the 1s individually whereas I'd like them evaluated from the date ranges:
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))
So i have been playing with Excel for a while, and one thing led to another, i wanted to try this: How would i calculate the instances of dates (such as below) in one sheet
And count which of those dates fall under the 30/60/90 day period (such as below) I'm looking to see if i could have a final tally up the number of instances of dates which fall below 30/60/90 days to the current date in another sheet.
Using the table example gave that i would know that 2 dates fall under the 30/60 days period, and one fell under the 90 days period
Is there a solution to my predicament?
Edit: More accurate question
Use nested IF() function.
=IF(TODAY()-B2<=30,30,IF(TODAY()-B2<=60,60,IF(TODAY()-B2<=90,90,"Other period")))
Or try IFS() if you have Excel-365.
=IFS(TODAY()-B2<=30,30,TODAY()-B2<=60,60,TODAY()-B2<=90,90)
Another option is-
=XLOOKUP(TODAY()-B2,{30,60,90},{30,60,90},"Other Period",1)
You could try:
Formula in E2:
=SUMPRODUCT(--(CEILING(D$6-B$2:B$6,30)=D2))
I need to count the number of employee who work in a particular hour:
For ex: My shift is 11:00pm to 8:00am, and I'm looking for the number of employees who's working within 11:00pm to 12:00am. My current shift is within the provided time (1 hour). If I'm looking for 8:00am to 9:00am and my shift is not within the provided time, then no count for me.
The problem is the formula doesn't counting time that passes midnight.
I tried several formulas and converted it into VBA code, but I failed. Here's the formula that I recently converted to code:
=COUNTIFS(B$2:B$7,"<"&F9,C$2:C$7,">"&E9)
and
=SUMPRODUCT(--(B2:B7<F2),--(C2:C7>F1))
Any ideas?
My solution utilizes two formulas.
Your current problem is to tell if a worker who works (for example) between 10:00pm - 3:00am. In order to reduce the risk of confusing the system, I opted to use a 24 hour clock. To minimize the need for input such as a date in addition to the time, I created a table as such:
Each cell contains the formula =IF($H$3>C3,IF(IF(C3>D3,D3+24,D3)>$H$3,"X",""),""). The cells under "Active?" displays an "X" as long as the worker is currently on the clock.
The cell to check how many employees are on the clock, it runs a simple count if formula =COUNTIF(E3:E6,"X") to count how many instances of "x" in the Active column are present.
To operate, you simply extend the range for any additional workers and fill out the cells accordingly. Once the table is populated, you can verify who is working by typing in the desired time in H3. Hope this helps!
I have a little problem with Excel. I nead to make a function that checks if a person is older that 19.
I checked for a function online but it does not work the way it should.
First I have a date in a unusual format 14 10 2012 , I used =SUBSTITUTE(J2, " ", ".")
to get 14.10.2012
after that I use a formula
=IF(P2<DATE(DAY(NOW()),MONTH(NOW()),YEAR(NOW())),"Older than
19","Too young")
but no mater what I do it does not work correctly. It shows the same resolute if the number is bigger or smaller
why is =DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY())) showing me 3.4.1920 ?
I think that you might have the parameters around the wrong way. If I put:
=DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY()))
into Excel, I also get 3.4.1920.
If, however, I enter:
=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))
I get 14.10.2012 - today's date!
======
Just as a followup, I suspect that you are trying to compare today's date with a date of birth to determine someone's age and whether they are over 19?
Try this:
Enter the formula above into a cell (hidden if you like) - lets call it A1
Have the person's date of birth entered into another cell - lets say A2
Enter the formula =A1-A2 into a third cell (A3). This gives you their age in days.
Another formula - this time =A3/365.25 (that is, their age in days divided by the number of days in a year). Let's say that's A4
It's then a simple IF statement =IF(A4>19,"Over 19","Too young")
Hope that helps :-)
=IF(YEAR(NOW())-RIGHT(J2,4)>55,"starejsi",IF(YEAR(NOW())-RIGHT(J2,4)=55,
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)>0,"older",
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)=0,
IF(DAY(NOW())-LEFT(J2,FIND(" ",J2,1))>=0,"older","younger"),"younger")),"younger"))
finally i have done it. this is the code