Excel Help: Search for Second/Third iteration to find matched status - excel

Two sheets of info
I've 2 sheets of data(but pasted in one sheet itself), in that I'm trying to find Status of each Job for a particular date based on the server name. And my formulas are working without any issues until no duplicates on the same date.
If the job runs twice / thrice on the same day then my condition fails. Now I want to add one more condition to qualify the time range.
Here is my conditions..
If the time is before 5 PM and the latest job which is near to 5PM is success then it should capture success.
And any jobs that is failed before 5 PM is a failure. And if it has Failed, Success, Failed before 5PM then it is Failed (coz the latest is failed).
Here I'm using one more formula to convert Text to Date format but I'm not converting time from that Text. Any help would be appreciated. And I'm fine to add one more column for Time aswell.
I'm using 2 formulas here..
=INDEX(I2:I8,MATCH(1,(A2=L2:L8)*(C1=J2:J8),0)) #to find status
=DATE((MID((TEXT(LEFT(K2,10),"mm/dd/yyyy")), FIND("/", (TEXT(LEFT(K2,10),"mm/dd/yyyy")), FIND("/", (TEXT(LEFT(K2,10),"mm/dd/yyyy")))+1)+1,256)),LEFT((TEXT(LEFT(K2,10),"mm/dd/yyyy")),FIND("/",(TEXT(LEFT(K2,10),"mm/dd/yyyy")))-1),(SUBSTITUTE(MID(SUBSTITUTE("/"&(TEXT(LEFT(K2,10),"mm/dd/yyyy"))&REPT(" ",6),"/",REPT(",",255)),2*255,255),",","")))
#to convert text to date

You could try this using 2 helper columns:
Helper Column 1 (Date)
Here I extracted the date from the field "Date & Time" with the following formula:
=DATE(RIGHT(MID(L2;1;FIND(" ";L2)-1);4);LEFT(L2;FIND("/";L2)-1);MID(L2;FIND("/";L2)+1;FIND("/";L2;FIND("/";L2)+1)-FIND("/";L2)-1))
Helper Column 2 (Flag Time)
Here I put a value to determine if the time is before 5 p.m. and which is the closer time to this hour.
First we have to extract the time value, so I used to formula to do it:
--MID(L2,FIND(" ",L2)+1,LEN(L2))
In order to determine if the time is before 5 p.m. I used (giving a greater value if the time is after 5 p.m.):
IF(Time<=17/24,0,10)
Finally I get a value related to how closer is the time to 5 p.m.
(17/24-Time)
And the final formula is:
=IF(--MID(L2,FIND(" ",L2)+1,LEN(L2))<=17/24,0,10)+(17/24-(--MID(L2,FIND(" ",L2)+1,LEN(L2))))
With these values on the helper columns now we can achieve what you're looking for. I'm using this array formula (don't forget to press Ctrl+Shift+Enter in order to works correctly):
=IF(SUM(($M$2:$M$8=$A2)*($J$2:$J$8=B$1))=0,"",INDEX($I$2:$I$8,MAX(IF(MIN(IF(($M$2:$M$8=$A2)*($J$2:$J$8=B$1),$K$2:$K$8,""))=($M$2:$M$8=$A2)*($J$2:$J$8=B$1)*$K$2:$K$8,ROW($I$2:$I$8)-1,""))))
And this is the result that we got:
You cand find an example here. (you have to download as an excel file to test it)

Related

Excel - Gantt Chart - Using Workday function - Workers Holidays

Good Afternoon,
I´ve developed a Gantt Grath on excel based on the workday() function to assess the end date of a task based on an inputted start date and duration. I´m now trying to improve that function by providing the annual leave days of each worker, based on a table where those days are marked with an "x" for each worker (please see the IMAGE 1 below).
I´ve worked the formula below. This formula looks for the worker name on the first column of the table, using a standard index() + match() pair and returns an array based on the days marked with an "x". That array is than used on the holidays field of the workday() function.
=WORKDAY($G$23,$H$23,IF(INDEX($B$8:$BA$18,MATCH($F$23,$B$8:$B$18,0),)="x",$C$7:$BA$7,"0"))
The problem that I´m having is that the workday() function does not count with the start date as a workday. As you can see on the second image, a task starting on the 02/10/2020 with a 3 day duration, and 2 day leave by the worker on the 05/10/2020 and 06/10/2020 should end on the 08/10/2020 and not 07/10/2020. (weekends, shown in yellow, are automatically disregarded by the formula).
I´ve already tried doing (-1) on the start date / duration added on the workday() but that just created other problems.
Can anyone help me in figuring out a solution for this problem. Thank you :)

Excel: Get the days delayed from Start date to End date Using DatedIF?

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

Calculate number of days between two dates if condition in another column is met

I need help with creating a formula for a status sheet (I'm horrible with if statements). I have three columns, Status, Start Date and Completed Date. I need a formula that will calculate the days between start and completed dates if the status is equal to Completed or Cancelled. If the status is not either of those it needs to calculate between start date and [today]. Is this possible?
Yes it is possible, something like this:
=if(or(Status="Completed",Status="Cancelled"),CompletedDate,Today())-StartDate
This should do it
=IF(A2<>"",C2-B2,TODAY()-B2)
..or this, if the other cells are containing some other word that doesn't start with C
=IF(ISNUMBER(SEARCH("C",LEFT(A2,1))),C2-B2,TODAY()-B2)
..also the third column could be renamed to "End Date" since cancelled isn't completed
..or this, if a start date is required to exist and to be smaller than the end date
=IF(B2>0,IF(AND(C2>B2,ISNUMBER(SEARCH("C",LEFT(A2,1)))),C2-B2,TODAY()-B2),0)

Excel: Count Total Schedules at 30 Minute intervals taking day into account

In assessing how many agents can be added to certain times of day without exceeding the number of seats in the call center, I'm trying to discern how many agents are scheduled for each half hour interval on each day of the week.
Using the =SUMPRODUCT(((A$2:A$1000<=D2)+(B$2:B$1000>D2)+(A$2:A$1000>B$2:B$1000)=2)+0) formula I've been able to identify how many total agents work for each interval, however this doesn't take the day of week into account.
I currently have my spreadsheet setup this way:
K is the start time of the shift, L is the end time of the shift, M to S pulls data from another sheet that shows a 1 if the agent works on that day of the week and 0 if they do not, and then U has all the time intervals listed out. In the example, it's cut off but the columns continue down as needed. U goes to 49 and I've just been using a range from 2 to 500 for the others as we currently do not have that many shifts and I'm leaving space for the moment.
After some Googling, I tried =SUMPRODUCT(--(M2:M500="1"),(((K$2:K$1000<=U2)+(L$2:L$1000>U2)+(K$2:K$1000>L$2:L$1000)=2)+0)) but it only returns #VALUE! so I'm not sure what I'm doing wrong.
Any suggestions of how I can make this work? Please let me know if more information would be useful. Thanks.
=sumproduct(($K$2:$K$1000<=U2)*($L$2:$L$1000>=U2))
That will count the number of occurrences where the start time is less than or equal to the time in U2 AND the end time is greater than or equal to U2. It will check time from row 2 to row 1000. Any time one condition is checked and its true the comparison will result in value of TRUE and FALSE when its not true. The * act like an AND condition while at the same time converts TRUE and FALSE values to 1 and 0. So both conditions have to be true for a value of 1 to result. Sumproduct then totals up all the 1 and 0 to get you a count.
In order to consider the days of the week, you will need one thing to be true. Your headers in M1:S1 will need to be unique (which I believe they are). You will need to either repeat them in adjacent columns to M or in say V1 you have a cell that can change to the header of the day of the week you are interested in. I would assume the former so you can see each day at the same time.
In order to do this you want to add more conditions and pay attention to you reference locks $.
In V2 you could use the following formula and copy down and to the right as needed:
=sumproduct(($K$2:$K$1000<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000))
UPDATE #1
ISSUE 1 Time ranges ending the following day (after midnight)
It is based on the assumption that the ending time is later than the start time. When a shift starts at 22:00 and end at 6:30 as an example, our mind says that the 0630 is later than 22:00 because it is the following day. Excel however has no clue that 0630 is the following day and without extra information assumes it to be the same day. In excel date is stored as an integer and time is stored as a decimal. When you only supply the time during entry it uses 0 for the date.
In excel the date is the number of days since 1900/01/00. So one way to deal with your time out is to add a day to it. This way excel will know your out time is after your in time when the hour is actually earlier in the day.
See your sample data below.
Using your sample data, I did a straight copy of the value in L and placed it in M (=L3 and copy down). I then changed the cell display format from time to general. This allows you to see how excel sees the time. Note how all the time is less than 1.
In column N I added 1 to the value when the out time was less than the in time to indicate that it was the following day and we had not actually invented time travel. I also used the trick of a math operation will convert a TRUE/FALSE result to 1 or 0 to shorten the equation. I used =M3+(L3<K3) and copied down. You will notice in the green bands that the values are now greater than 1.
In the next column I just copied the values from N over using =N3 copied down, and then I applied just a time display format for the cell. Because it is only time format, the date is ignored and visually your time in column O looks the same as column L. The big difference is excel now knows that it is the following day.
you can quickly fix your out times by using the following formula in a blank column and then copying the results and pasting them back over the source column using paste special values.
=M2+(L2<K2)
The next part is for your time check. When looking at the 12:00 time you need to look at 1200 of the current day incase a shift started at 12:00 and you need to look at the 1200 period of the following day. In order to do that we need to modify the the original formula as follows:
=sumproduct(($K$2:$K$1000<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000)+($K$2:$K$1000<=$U2+1)*($L$2:$L$1000>=$U2+1)*(M$2:M$1000))
Note that the + in the middle of (M$2:M$1000) + ($K$2:$K$1000<=$U2+1)? This + acts like an OR function.
Issue 2 Time In/Out 15 minute increments, range 30 minute increments
You may be able to achieve this with the ROUNDDOWN Function or MROUND. I would combine this with the TIME function. Basically you want to have any quarter hour start time be treated as 15 minutes sooner.
=ROUNDDOWN(E3/TIME(0,30,0),0)*TIME(0,30,0)
Where E3 is your time to be converted
So your formula may wind up looking something like:
=sumproduct((ROUNDDOWN($K$2:$K$1000/TIME(0,30,0),0)*TIME(0,30,0)<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000)+((ROUNDDOWN($K$2:$K$1000/TIME(0,30,0),0)*TIME(0,30,0)<=$U2+1)*($L$2:$L$1000>=$U2+1)*(M$2:M$1000))
similar option could be used for the leaving time and rounding it up to the next 30 minute interval. In which case just use the ROUNDUP function. Though I am not sure it is required.

Formatting Existing Excel Cells to Time Format Without Date

I'm working on an excel 2010 sheet where I mark down the date and time an event happens. The date is in one column, and auto formats to 17-Nov when I would type in 11-17 (I was fine with this). The time is in a separate column.
I am trying to find the average time an event occurred, without regard to the date, so I would use =AVERAGE(C1:C10). However, I only receive a date back (like 17-APR).
I did not format the cells before I began to enter in data, and I would simply type in a 3:27pm event as 1527, and no reformatting would happen.
Now, when I attempt to reformat the column to hhmm, all the numbers entered so far turn to 0000. When I try to edit the 0000, it is formatted as 6/13/1906 12:00:00 AM.
What I want to do is have the time formatted as hhmm and not include a date in the cell, and be able to run formulas on it, such as the average time an even occurred.
Summary:
*Currently time is entered simply as ####. I entered 3:27pm as 1527.
*Trying to reformat the time column results in 0000 in all cells in the column that previously had a ####.
*Modifying the 0000 displays as 6/13/1906 12:00:00 AM
*I want to format the time as hhmm so I can simply type in 2357, and have it display as 2357, but understand I mean 11:57pm, and let me take averages.
*Hell, even being able to enter 1547 and have it auto format to 15:47 or 3:47p would be great.
Thanks for reading my question!
An easy way to apply an autoformat (though Excel won't see it as a true "Time") is to go into Format Cells>Custom> and use ##":"##. This will turn 1245 into 12:45. Mind you, this will be a text string so if you copy it to another cell and then apply a time, it will show as 12:00:00. Excel will also not be able to run formulas on it, but it's a quick and dirty way to make it look pretty.
Another option is to have a formula such as =TIME(LEFT(A1,2),RIGHT(A1,2),) where A1 would be replaced with the cell you are actually referencing. This will convert the number to a time that Excel will recognize as a time allowing you to run other functions on it, but requires another column.
If you are entering the times as 4-digit numbers, you'll need to do a calculation to get the hours and minutes, then use the TIME function to get an actual time:-
=TIME(A1/100,MOD(A1,100),0)
Another way is
=LEFT(A1,2)/24+RIGHT(A1,2)/1440
but then you have to format the result as a time.
Excel sees a number like 1547 as approximately 4 years on from 1st January 1900 if you format it as a date, so it will come out as something like 26/3/1904 in UK format or 3/26/1904 in US-style format.
Note that the time function can only give you values up to 23:59:59 (stored as 0.999988426), but the second method will give you a datetime value with one or more days as the whole number part. This can be useful if you want to do calculations on times spanning more than one day.
The above behaviour is because dates and times are stored as real numbers with the whole number part representing days and the decimal part representing fractions of a day (i.e. times). In spite of misleading information from Microsoft here, dates actually start from 31/12/1899 (written as 0/1/1900) with serial number 0 and increment by 1 per day from then on.

Resources