Excel Help

Status
Not open for further replies.

Azzkiker

Ars Scholae Palatinae
990
Originally posted in MS OS forum, but wasn't getting many views... maybe someone here can help?

So I am trying to create a time log that tracks time on, and time off... The spreadsheet needs to calculate time off between shifts across one or more days.

I would like the spreadsheet to recognize days off (24:00+ off times), and show text such as "OFF" or even 0:00:00 in the rest period field, but hand the data behind it forward so that any given day (other than days off?) shows the total of rest hours between shifts. Failing that, if a given days rest period is less than 10 hours, to check the previous days, and if the previous day/days have 24+ rest hours then post 10+ or 10< in the that days field.

The idea is that in my field you have to have 10 hours rest before working, and while the current format works, it doesn't quite look right at first glance.

So far I have this




SAb8s.jpg


Any ideas if what I am trying to do is possible?

here is a link to what I've created up to this point.

http://www.mediafire.com/file/eelsrqr8y ... melog.xlsx
 

Alamout

Ars Legatus Legionis
27,285
I think you've made it a bit overcomplicated. Instead, try this: calculate "evening rest hours" column as (24 - off_time) + (evening_rest_hours_yesterday if off_time == 0 else 0).

In Excel: E[n] = 24 - C[n] + IF(C[n] = 0, E[n-1], 0)

(actually to get this to work I had to use a fixed cell for 24:00:00 and refer to that. I don't know why Excel doesn't allow using the number)

That column will be the consecutive rest time up to midnight for that day, and it will correctly propagate down the spreadsheet. You can then use that to calculate the rest for the start of the day (let's say column F):

F[n] = 24 - B[n] + E[n-1] (again I had to use a fixed cell for 24:00:00 for some reason...)

And you can use IF statements if you want it to output something else in certain scenarios (like 10+ or whatever). You need the first column though, to keep track of the actual rest time.
 

Inscitia

Ars Tribunus Militum
1,752
Ok.. wow. It took me a while to figure out what you were doing - and you're right, it doesn't look right.

I've fixed it, to what I believe you want to achieve:

http://www.inscitia.com/Timelog_Inscitia2.xlsx

Namely, instead of having a single row for each date (why??) you enter the date where people work, and their shift hours.

This allows a (much easier) formula to be created:

=IFERROR(((([@Date]-INDEX([Date],MATCH([@Date]-0.5,[Date],1),1))-1)*24+("24:00"-INDEX(ShiftTable,MATCH([@Date]-0.5,[Date],1),4))*24+

Well, easier for me anyway.

Specifically, this formula:
  1. Locates the previous date. This requires the list to be in ascending order - which makes the MATCH function superfluous, so feel free to remove it. Oops.
  2. Adds up the hours for the missing days, plus hours between previous shift end and midnight, and between day start and shift start for the current day.
  3. Divides by 24, allowing the data to be formatted as a Time cell.

Edit:

So I updated the spreadsheet at the link above, partly because I've (oddly enough) never had to use MATCH or something similar on an unordered list. The linked spreadsheet should work even when the order becomes FUBARED - it adds a dynamically calculating index field:

=IF(MIN([Date])=[@Date],1,INDEX([Index],MATCH([@Date]+MAX(IF(([Date]-[@Date])*1*([Date]<[@Date])<0,([Date]-[@Date])*1*([Date]<[@Date]))),[Date],0),1)+1)

...which is kind of an absurd formula to do something very simple. Perhaps I'm missing something? Still, it was quick to write.

That simplifies the hour calculation formula slightly:

=IFERROR(((([@Date]-VLOOKUP([@Index]-1,ShiftTable,2))-1)*24+("24:00"-VLOOKUP([@Index]-1,ShiftTable,5))*24+[@Begin]*24)/24,"")
 

Azzkiker

Ars Scholae Palatinae
990
Thanks for the replies guys... :bigdumbgrin:

Inscitia that is really close to what I need, is there any way to do this with all days in a given month shown rather than excluding off days from the worksheet?

You asked why in your post, and I just noticed... The form needs to follow the same format month to month... look the same, same shape/size/feel etc... audits go smoother when everything stays the same :D

I supposed I could use the "index" column in your worksheet and run a list "days worked" 1-31 or something like that, that might fit.
 

Inscitia

Ars Tribunus Militum
1,752
Azzkiker":lzqp9k43 said:
Inscitia that is really close to what I need, is there any way to do this with all days in a given month shown rather than excluding off days from the worksheet?

Probably? I'd prefer not to make that.

You could always just create another table (e.g. for reporting) that listed all days in the month and then looked up whether or not a shift had been entered; IFERROR call it an OFF day.
 
Status
Not open for further replies.