I have a list of date timestamps and if any of the times happen outside of our working hours, I need to advance them forward to the start of the next workday.
Our work hours are M-F 8:30am-5:30pm, Saturday 8:30am-1:30pm, Sunday closed and we are also closed on holidays.
Examples:
Friday June 26, 2020 6:30pm should be advanced to Saturday June 27, 2020 8:30am
Friday July 3, 2020 6:30pm should be advanced to Monday July 6, 2020 8:30am. Because Saturday was a holiday and we are closed on Sunday.
Friday July 3, 2020 5:29pm should not be advanced because it began during work hours
Column A |Column B | Column C | Column B | Column E
Underwriter | LoanNumber | EntryTime_+3hrs | Desired Outcome | HOLIDAY
TOM | 1 | 07/31/2020 8:28:42 AM | 08/01/2020 8:30:00 AM | 01/01/2020
DICK | 2 | 07/30/2020 6:32:36 PM | 07/31/2020 8:30:00 AM | 01/20/2020
JANE | 3 | 07/30/2020 4:18:57 PM | 07/30/2020 4:18:57 PM | 02/17/2020
BETH | 4 | 07/30/2020 3:06:18 AM | 07/30/2020 8:30:00 AM | 05/25/2020
SALLY | 5 | 07/29/2020 6:35:37 PM | 07/30/2020 8:30:00 AM | 07/04/2020
GEORGE | 6 | 07/03/2020 7:45:26 PM | 07/06/2020 8:30:00 AM | 09/07/2020
| | | | 10/12/2020
| | | | 11/11/2020
| | | | 11/26/2020
| | | | 12/24/2020
| | | | 12/25/2020
Start date time stamps need to be validate and converted to next available time slot.
Current thinking is you have three potential outcomes:
The date will need to be shifted next possible day starting at 0830
The date will remain the same but the time will be shifted to 0830
The date and time are valid and no adjustment is required.
so a generic formula might look something like this:
IF(OR(HOLIDAY,SUNDAY,AFTERHOURS),FIND NEXT WORKDAY,
IF(BEFORE WORKHOURS, SET TIME TO START TIME, ITS VALID TIME))
In order to check each condition individually for a potential day shift we can use the following formulas:
(ASSUME C2 is the start date being tested)
WEEKDAY AFTER 1730
=AND(MOD(C2,1)>TIME(17,30,0),OR(WEEKDAY(C2)={2,3,4,5,6}))
SATURDAY AFTER 1330
=AND(MOD(C2,1)>TIME(13,30,0),WEEKDAY(C2)=7)
HOLIDAY (list in E2:E12)
=COUNTIF($E$2:$E$12,INT(C2))=1
SUNDAY
=WEEKDAY(C2)=1
The MOD function in the first two formulas is stripping the Integer/date value and just keeping the decimal/time portion
The { } is a manual list/array is a nice way of doing multiple OR checks with out writing out each individual check. Since these are sequential, you do have other options.
Now there is a way of flagging each case, So now just rearrange and group together so you have three choices in a nested IF function:
=IF(OR(AND(MOD(C2,1)>TIME(17,30,0),OR(WEEKDAY(C2)={2,3,4,5,6})),AND(MOD(C2,1)>TIME(13,30,0),WEEKDAY(C2)=7), COUNTIF($E$2:$E$12,INT(C2))=1, WEEKDAY(C2)=1), FIND NEXT DATE, IF(BEFORE WORK, SET TIME TO 0830, DO NOTHING))
Since each valid day starts at 0830 and invalid days have already been taken care of with the first IF, only the start time needs to be checked.
=MOD(C2,1)<TIME(08,30,00)
And the valid time is the only case left over so there is nothing to check for.
And you pseudo formula becomes something like:
=IF(OR(AND(MOD(C2,1)>TIME(17,30,0),OR(WEEKDAY(C2)={2,3,4,5,6})),AND(MOD(C2,1)>TIME(13,30,0),WEEKDAY(C2)=7), COUNTIF($E$2:$E$12,INT(C2))=1, WEEKDAY(C2)=1), FIND NEXT DATE, IF(MOD(C2,1)<TIME(08,30,00), SET TIME TO 0830, DO NOTHING))
So now you just need to figure out how to add some days, change the time, and keep what you have for a value.
Adjusting the number of days to add had me looking at multiple nested IF equal to the number of days in a row that could be invalid. Right now I have the worst case scenario being Thursday at 17:31 something starts. Friday is a holiday as a result of a holiday on Saturday, Sunday is a holiday, and Monday is a holiday due to the Sunday holiday. So first potential day would be 5 days away. Ugly nested IF. As an alternative I looked at AGGREGATE and adding 1 day at a time up to 5 and checking if its a valid date. Then take the lowest/earliest date and setting start time to 0830. To achieve this I tried the following formula:
=AGGREGATE(15,6,(INT(C2)+{1,2,3,4,5})/((COUNTIF($E$2:$E$12,(INT(C2)+{1,2,3,4,5}))<1)*(WEEKDAY(C2+{1,2,3,4,5})<>1)),1)+TIME(8,30,0)
Then next function you need to do is keep the date but set the time to 08:30
=INT(C2)+TIME(08,30,00)
and your do nothing is:
=C2
so now if we combine the crap out of that into one formula we wind up with:
=IF(OR(AND(MOD(C2,1)>TIME(17,30,0),OR(WEEKDAY(C2)={2,3,4,5,6})),AND(MOD(C2,1)>TIME(13,30,0),WEEKDAY(C2)=7), COUNTIF($E$2:$E$12,INT(C2))=1, WEEKDAY(C2)=1), AGGREGATE(15,6,(INT(C2)+{1,2,3,4,5})/((COUNTIF($E$2:$E$12,(INT(C2)+{1,2,3,4,5}))<1)*(WEEKDAY(C2+{1,2,3,4,5})<>1)),1)+TIME(8,30,0), IF(MOD(C2,1)<TIME(08,30,00), INT(C2)+TIME(08,30,00), C2))
I believe the desired date in D2 (red background) is wrong and should instead be 20/07/31 08:30
reference to your previous question
Now in theory this could be substituted for every B2 reference in the first formula, but A) the thing would become even more damned unreadable and hard to maintain than it already is, and B) may cause multiple repetitive calculations.
So my company services clients with insurance products and we have two teams: Liability and Crime. There are generally one 4 different types of task: Binding, Issuance, Quoting and Rapids.
I currently have made a spreadsheet based on data obtained through our workflow.
The main formulas I use to calculate service due date for Crime/Liability team is:
=IF(OR(WEEKDAY(IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))=1,WEEKDAY(IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))=7,IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))+2,IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))
Where you have 3 hours to finish binding, quoting, rapids, and you have two days for issuance.
We are now expanding our service to California, which is three hours behind EST time, so now comes the issue: We want to expand our working hours (est time) to 9 am - 8 pm to cover west coast. But, does is it possible to tell excel to do that via a weekday/workday function?
The goal is to have the due dates wrap around weekends to Monday and anything after 8 pm (est time) to being due next day.
For example: If a binding task comes in at 7:00 pm, then you would have 1 hour till 8 pm, and so the task would be due at 11:00 am the next day. Is this even possible to do with just excel? Any help would be immensely appreciated guys, thank you!
Your formula can be simplified greatly if you have a lookup table in your workbook somewhere that returns the due time values. For the example below, my lookup table is in Sheet2, A1:
Sheet 1 - Example Data
| A | ... | C | D |
+--------+ ... +-----------------+----------------+
1 | Task | | Received | Due |
2 |Binding | |19/02/2018 09:00 |19/02/2018 12:00|
3 |Quoting | |19/02/2018 13:00 |19/02/2018 15:00|
Sheet 2 - Lookup table:
| A | B |
+--------+-------+
1 |Binding | 0.125 |
2 |Quoting | 0.125 |
3 |Issuance| 2 |
4 |Rapids | 0.125 |
Formula
The formula in Sheet1 D2 is:
=C2+INDEX(Sheet2!B:B,MATCH(Sheet1!A2,Sheet2!A:A,0))
From there it should be a lot simpler to construct an IF STATEMENT to rollover to the next day if the order is received past 5pm (would be due after 8pm).
I receive a statement (as a .xls) each month which list a bunch billable items with an associated date. I want to create a formula (using either =sum() or =sumifs() to total the billable items, but only those which fall Monday to Friday (i.e., not weekends). Is that possible?
A B
------+--------------+-------------
1 | 05/12/2016 | $10.00
2 | 06/12/2016 | $10.00
3 | 07/12/2016 | $10.00
4 | 08/12/2016 | $10.00 dates are formatted as
5 | 09/12/2016 | $10.00 dd/mm/yyyy
6 | 10/12/2016 | $10.00
7 | 11/12/2016 | $10.00
8 | 12/12/2016 | $10.00
------+--------------+-------------
| Sum | $80.00
------+--------------+-------------
| Sum |
| (no weekends)| $60.00
------+--------------+-------------
EDIT:
I've just looked closer at the excel doc, and it's actually a datetime field, e.g. 31/10/2016 12:44:00 pm (displayed as 31/10/16 12:44).
I'm also not looking for a formula which works line by line, I'd like something which I can just copy and paste into a single cell at the bottom of the doc each month which examines A:A.
You need to use this formula:
=SUMPRODUCT(B1:B8,--(WEEKDAY(A1:A8,2)<6))
This is a hack which behaves like SUMIF but lets you use a function in your criteria. Otherwise, you would need to create an auxiliary column with WEEKDAY (in C for example) and then use =SUMIF(C1:C8,"<6",B1:B8).
WEEKDAY by default returns 1-7 for SUN-SAT. As this doesn't help, you can change the return type to type 2 with the optional second parameter to make the function return 1-7 for MON-SUN, which lets you do the easy <6 comparison. You can also use type 3, which returns 0-6 for MON-SUN, and then obviously use <5 instead.
More about the -- hack here.
I have a table of data that has a format similar to the following:
EventID | Event Date
--------------------
1 | 1/1/2014
2 | 2/8/2014
3 | 10/1/2014
4 | 2/5/2014
5 | 4/1/2014
6 | 9/1/2014
What I am trying to do is create a DAX formula to rank each event in the order that it happened for the year. So I want to end up with something like this. This way I can compare the events year over year as the events don't happen on any regular time schedule.
Event Date | Year | Rank
------------------------
1/1/2014 | 2014 | 1
2/8/2014 | 2014 | 2
10/1/2014 | 2014 | 3
2/5/2015 | 2015 | 1
4/1/2015 | 2015 | 2
9/1/2015 | 2015 | 3
I have tried to do this by creating a formula that will give me the day number of the year:
Day of Year =(YEARFRAC(CONCATENATE("Jan 1 ", YEAR([Event Date])),[Event Date])*360)+1
Then using rankX on this table, but I cant seem to get the proper result. Perhaps I am not understanding the use of rankX or going about this the right way.
=RANKX(FILTER(Event,EARLIER(Event[Event Year])=Event[Event Year]),Event[Day of Year])
or
=RANKX(All(Event[Event Year]),[Day of Year],,1,Dense)
Any ideas would be much appreciated!
Thanks for any help in advance!
Create the following measures:
[Year]:=YEAR(LASTDATE(Event[Event Date]))
and
[Rank]:=RANKX(FILTER(ALL(Event),[Year]=YEAR(MAX(Event[Event Date]))),FIRSTDATE(Event[Event Date]),,1,DENSE)
and this is the result that you get:
Note: My dates are in UK format and I suspect yours were in US format, so the rankings do not appear to tally with your example, but it does work!
I've doing these manually for the last for the last year and hoping I can get some help and guidance on how to execute this better using Excel
Sheet 1
Client Name | SKU | Description | Oct Qyt | Oct fee | Nov Qty | Nov Fee | Dec Qty | Dec Fee | Total
John, Doe | 1234 | red wine | 12 | $12 | 12 | $12 | 12 | $12 | $36.00
John, Doe | 3456 | white wine | 6 | $6 | 3 | $3 | 0 | $0 | $9.00
Kent, Clark | 6789 | etc..
Same client has multiple SKUs and SKUs vary in quantity each month and I need to figure out the total.
I need to translate the above data to one invoice by client name:
SKU, Description, Oct Units, Fee, Nov, Units, Fee, TOTAL.
Is there a way to easily process this in macros or with vlookups? I tried vlookups and, since there are multiple products under one person, it's not working properly.
I need to do this to generate over 150 invoices, save them individually, convert to pdf, and email it to clients.
Absolute easiest way would be with a pivot table.
If you want to do something using macros, you could start by creating a sheet for each client. I use this macro sometimes by highlighting a distinct list of names and running the macro:
Sub CreateSheetsWithTheseNames()
Dim CurName As Range
For Each CurName In Selection
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = CurName.Value
Next CurName
End Sub
This could be modified to just look through column A and creating sheets for every name that does not already have a sheet with that name.
If you had a pivot table setup already, the above macro could be modified to copy the pivot table sheet for each client and filtered accordingly. From there, each sheet can be saved as a PDF.
I could probably expound some on the macros if need be.
For the sake of an answer.
Try a PivotTable, with Client Name in Report Filter, SKU and Description in Row Labels and Sum of each of Oct Qyt, Oct fee, Nov Qty, Nov Fee for Σ Values.