Excel - Find if worker has worked certain OT if weekday and or Sunday - excel

I have a worksheet with days running along the columns, within each day there are different hourly categories, 130%, 150%, 200% and 215% etc, there are other categories within each day, but these are not to be included. (Can't post Image as new, can email?)
If a worker works over 3.5 hours in any of these categories they get an extra lunch, except on Sunday's where they must work 4 hours.
I've been using countif's to check each day over 3.5, and another column for Sunday's.
The weekday and Sunday can be combined into the same column as the lunch price is still the same, just number of working hours different.
The main problem is I have to adjust the countif's every month, I want something that will look at days of the week and/or sunday's and check without adjusting every month.
Have been trying to get my head around sumproduct with countif!
Any help, very much appreciated.
Thanks!

Since you have not mentioned what is where this might take some adjustment, but may get you started:
=IF(SUM(B3:G3)>=IF(WEEKDAY(B$1)=1,4,3.5),"lunch","no lunch")

Related

Excel subtract X days from date and then find last specific workday date

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))

Working out number of days between 2 dates based on a specific premise

I'm wondering if anyone can help me. I have a spreadsheet which I use to populate scheduled meetings of various venues (at the moment these dates I enter in manually from a reference sheet as I don’t know how to do it with a formula).
Each week, when staff go to the venue for their meeting I then enter in (again manually) what date they actually went to the venue for the meeting.
What I then have to do, is work out if they went to the meeting within our agreed time-frame, and if not, how many days late were they. However, this calculation part will just take days to do by hand as there are so many meetings to analyse.
To work out if someone is within time frame or is late, it works on this premise:
If your meeting was scheduled to take place in say week 40, you have until the Friday of week 41 to go. Any working day after that is a day late (so if for example you ended up going to the meeting on the Tuesday in week 42 you would be 2 days late). Weekends and holidays should not be included in the calculation as staff don't work on bank holidays.
The link shows an example of how this looks - you can pretty much ignore the first tab as that's just me working out some example dates to put into the main tab and the last tab is the bank holidays for the remainder of this year and next.
https://docs.google.com/spreadsheets/d/1KaEAB59311W8_M1FdAL96753SirqY3dtl4eTzIruzK8/edit?usp=sharing
Thanks so much in advanced for reading this, and if anyone is able to help or has any ideas on how to even get started with this I’d really welcome your thoughts !
Okay, this was my best attempt at this for the time I've got now - This will work if the max amount of time that a scheduled meeting can take place is up to 2 weeks beyond the original limit - anything more than that and it will be off, but you could change that IF formula to account for that:
=IF(D2-(B2+13-WEEKDAY(B2))<0,0,IF(D2-(B2+13-WEEKDAY(B2))>7,D2-(B2+13-WEEKDAY(B2))-4,D2-(B2+13-WEEKDAY(B2))-2))
Screenshot from posted file:

Turnaround Time excluding Weekends

Hi i need to get the turnaround time of this columns excluding the weekends. I tried to subtract it but without the excluding the weekends, so i am not successful to get the right turnaround time needed. Please help me to get the right formula for excluding the weekends of this sample. Thanks
As you can see here, this is the data that i need to get the TURNAROUND TIME, so what i did is column N subtract to column M.
This is the formula i used to see the results with correct format but i want to have a result which will have a exclusion of weekends but i don't know how to do it.
How about using the following formula, this will calculate the Work Days between two dates:
=NETWORKDAYS(N2,M2)
Since the comments in the old answer have grown - to the extent that the question needs editing to include all of the "additional" requirements (and there are various reason why these chameleon questions are often frowned upon. For any more "tweaks", raise a new question.) - I am posting the updated code here.
First: Since NETWORKDAYS counts from the Start of the first day to the End of the Last day, it tends to add an "extra" day. To fix this, we need to remember to subtract the first-part of the first day (midnight to start time) and the last part of the last day (end time to midnight) - but only if they are each Workdays.
=NETWORKDAYS(M2,N2)+IF(MOD(WEEKDAY(N2),7)>1,MOD(N2,1)-1,0)-IF(MOD(WEEKDAY(M2),7)>1,MOD(M2,1),0)
Next, was the requirement to exclude Holidays. IMPORTANT! This requires that you have a Worksheet called "Holiday Sheet", with a list of the Dates of your Holidays in Column A.
We use ISERROR(MATCH(..)) as a check for "Not in the list", and NETWORKDAYS accepts the list the third, optional, argument/parameter
=NETWORKDAYS(M2,N2,'Holiday Sheet'!$A:$A)+IF(AND(MOD(WEEKDAY(N2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MOD(N2,1)-1,0)-IF(AND(MOD(WEEKDAY(M2),7)>1,ISERROR(MATCH(M2,'Holiday Sheet'!$A:$A,0))),MOD(M2,1),0)
The last "extra" requirement was to calculate this as Working Hours, with a workday running from 07:00 to 16:00 - a 9 hour day. To start, multiply NETWORKDAYS by 9 hours (TIME(9,0,0)), and then remember to remove the first-part of the first day (corrected for working hours) and the last part of the last day (also corrected for working hours).
We can use MEDIAN to get the middle number from 3 values, so that we never use a time before 07:00 or after 16:00
=TIME(9,0,0)*NETWORKDAYS(M2,N2,'Holiday Sheet'!$A:$A)+IF(AND(MOD(WEEKDAY(N2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MEDIAN(TIME(7,0,0),MOD(N2,1),TIME(16,0,0))-TIME(16,0,0),0)-IF(AND(MOD(WEEKDAY(M2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MEDIAN(TIME(7,0,0),MOD(M2,1),TIME(16,0,0))-TIME(7,0,0),0)

Excel Formula for calculating time in round numbers with hours text

I'm trying to figure out a way to create an excel spreadsheet that will allow me to keep track of how many hours I've earned per each paid holiday my company offers, then keep track of how many hours I've used and what's remaining. But I'm unsure how to calculate this properly.
I could easily do the math my self as it's a simple lay out, but I'm trying to find a way that will just let me enter the numbers for earned and used and walk away from anything else.
What I'm trying to do is the follow:
Have multiple sections. In the first section it'll be my holidays. So in like Column A, working down I'd have New Years, Memorial Day, July 4th, etc. Column B working down would be time earned. But this would be labeled in each cell as "8 Hrs" or "4 hrs". Column C would be time used in the same format "4 hrs" "8 hrs". Then Column D would simple be hours remaining.
Now in the second section I'd have holiday hours earned, which is 2 weeks. Not too sure how to lay it out, and then I still have my sick days, but not sure if I should include that in section 2 or not with the vacation time.
I'd like a way to be able to simply Calculate B2 - C2 = D2. So 8 Hrs - 4 Hrs = 4 Hrs (to show 4 Hrs remaining for each line item.)
Problem is I'm unsure how to calculate remaining time simply because of the Hrs suffix. And with that I also can't calculate total time still remaining, both for holiday hours earn and vacation/sick hours.
Yes, it's easier for me to track it as 8 Hrs rather than 1 day, etc.
Any advice on how to formulate this. Or if anyone knows of a premade template that fits this type of scenario, that I could then just take and integrate into my own spreadsheet.
Sorry if this is confusing in any way.
Also, As I'm no excel wizard, unsure if this is relevant or not, but I'm using Excel 2016, as part of the Office suite.
Another option is to just leave the number as it is and label the column accordingly. Do you really need to see "hrs" in every cell when you know you are tracking hours?
Use a custom number format of,
[>1]0 \H\r\s;[=1]0 \H\r_);0 \H\r\s;[Red]#
... and treat all hours as integers.

Calculate annual leave between two dates in Excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.
All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.
To be more clear, this example shows one employees contracted hours from Monday to Sunday i.e. they work only Weds, Thurs, and Friday, for 7.5 hours each day.
Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.
Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))
If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))
- it is a bit long-winded but the only way I can think of at the moment.

Resources