Error fields in Numbers timesheet / pay calculation table due to blank future hours fields.

Figured out how to calculate Hours from Start Time and End Time columns, and Total Daily Pay from Hours using DUR2HOURS function, but now seeing red error alerts in the remainder of the Total Daily Pay column. Since I haven't worked those days yet, values were blank in the Hours column, which Numbers is autofilling with zeros in all "future" fields. Numbers doesn't seem to like when these fields = 0, so it's giving red error symbols in all remaining fields of the Total Daily Pay column, including the Total Sum at the bottom.


Does anyone know a way around this or a better way to format this? (I tried an IF clause to see if I could get Numbers to ignore the zeros in the Hours column, or give me zeros in Total Daily Pay column instead of error alerts, but couldn't get that to work.)

Posted on Jan 5, 2024 5:52 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 7, 2024 10:05 PM

Aliveinabrokenworld wrote:

I now have zeros instead of error messages in future fields under Hours and Total $. Is there a way to make them stay blank without error fields? Just seems messy and dumb.


I tend to leave formulas simpler so they show error triangles with sometimes useful error messages (which appear when you click on them), and then just don't keep blank rows in the bottom of the table. However, if you want a neater appearance while still having blank rows at the bottom then you can do something like this:



In E2, filled down:


=IF(OR(ISBLANK(B2),ISBLANK(C2)),"", MOD(C2−B2,"1d")−D2)


In F2, filled down:




=IF(ISNUMBER(E2),DUR2HOURS(E2)*Rate::$A$2,"")


This is based directly on the built-in 'Employee Schedule' and took about 10 minutes to modify.


Because of the MOD it doesn't care what dates are in your In and Out columns and gives the expected result if you start a shift in the evening and end it past midnight. In fact you could just format your In and Out columns as Text, enter "just the times", and Numbers will still happily do the time calculations for you


SG

Similar questions

15 replies
Question marked as Top-ranking reply

Jan 7, 2024 10:05 PM in response to Aliveinabrokenworld

Aliveinabrokenworld wrote:

I now have zeros instead of error messages in future fields under Hours and Total $. Is there a way to make them stay blank without error fields? Just seems messy and dumb.


I tend to leave formulas simpler so they show error triangles with sometimes useful error messages (which appear when you click on them), and then just don't keep blank rows in the bottom of the table. However, if you want a neater appearance while still having blank rows at the bottom then you can do something like this:



In E2, filled down:


=IF(OR(ISBLANK(B2),ISBLANK(C2)),"", MOD(C2−B2,"1d")−D2)


In F2, filled down:




=IF(ISNUMBER(E2),DUR2HOURS(E2)*Rate::$A$2,"")


This is based directly on the built-in 'Employee Schedule' and took about 10 minutes to modify.


Because of the MOD it doesn't care what dates are in your In and Out columns and gives the expected result if you start a shift in the evening and end it past midnight. In fact you could just format your In and Out columns as Text, enter "just the times", and Numbers will still happily do the time calculations for you


SG

Jan 7, 2024 3:33 PM in response to Aliveinabrokenworld

Alive,


This solution is in my style. It may not suit you, but this is where I've landed after a few years of using spreadsheets.



I like to use a Constants Table. I simplifies some expressions and makes the sheet easier to maintain if, say, the hourly rate changes.


Here are the expressions, as found in Row 2:


Duration: =IFERROR(IF((C2−B2−D2)<Constants::A$2,C2−B2−D2+Constants::B$2, C2−B2−D$2), "")


Hours: =IFERROR(DUR2HOURS(E2), "")


Pay: =IFERROR(F2×Constants::$C$2, "")


You can "Hide" the Duration field, or the Hours field, or leave them both there. If you leave Duration visible, you may want to rename it.


If you look past the IFERROR function that is only there for the case of empty entry cells, it's a pretty simple set of expressions. The Duration expression is only as complicated as it is to accommodate hours that span Midnight. It might not be necessary to test for the negative result in your case.


I hope seeing this solution style is helpful.


Jerry



Jan 5, 2024 9:57 PM in response to Aliveinabrokenworld

Your solution changes the duration D3-C3 to a decimal value then back to a duration. That isn't necessary. An alternate solution that also deals with workshifts that span midnight and handles time entries that are made/edited on later dates (and therefore have the wrong date associated with the time),


IF(OR(C3="",D3=""),DURATION(0),MOD(D3−C3,DURATION(,1)))


Format as duration with units of hours and minutes.


Jan 7, 2024 4:01 AM in response to Badunit

Here's what my table looks like with the hectic formula DURATION(,,IF(OR(Start Time Jan 1="",End Time Jan 1=""),0,DUR2HOURS(IF(Start Time Jan 1>End Time Jan 1,End Time Jan 1+1,End Time Jan 1)−Start Time Jan 1) ))−Break Jan 1)



I now have zeros instead of error messages in future fields under Hours and Total $. Is there a way to make them stay blank without error fields? Just seems messy and dumb.

Jan 5, 2024 6:22 PM in response to Aliveinabrokenworld

Oh I discovered the IFERROR function and applied to the Total Daily Pay formula. It of course changed the error fields to blank fields.


I'm still unsure whether this is a good solution or whether there would have been a better way to go about these table formulas. I'm obviously a novice at numbers and was never an Excel pro. Been hacking my way through with a combination of trial and error and asking Google questions.

Jan 7, 2024 6:26 PM in response to Aliveinabrokenworld

Late to the party, but the built-in templates at File > New in the menu are instructive, often deceptively simple and elegant, and can save hours of "reinventing the wheel."


Here's a screenshot of the template called 'Employee Schedule'.




Remove the Employee column and you've got a working document in just a few minutes.


The "crossing midnight" problem, if you have it, is easily addressed with MOD, as Badunit explains.


SG

Jan 5, 2024 10:37 PM in response to Aliveinabrokenworld

Hi Aliveinabrokenworld,


To answer this question,

Aliveinabrokenworld wrote:

However, now I can't seem to figure out how to integrate that into this original formula I was using to solve the problem of anomalous shifts whose end times were < start times (like overnight shifts:)

IF(StartTime>EndTime,EndTime+1,EndTime)-StartTime

Stringing the second IF clause after the end of the first formula did not seem to work, and I tried many other variations in attempts to combine them.


Welcome to the "Crossing Midnight" problem!

You are on the right track.


This may help. I added extra columns (C and D) to display the full Date & Time.

I prefer the "h m" display for Duration formats and "am/pm" for time of day. That way my old brain does not confuse the two.

Times entered on the actual Start and Finish days work as expected.

Times entered on the same day require +"1d" to correct the "Crossing Midnight" problem.



Formula in E2 is B2−A2

Easy, but could be wrong!


Formula in F2 is IF(B2<A2,B2−A2+"1d",B2−A2)

To catch and correct "Crossing Midnight".


Regards,

Ian.

Jan 6, 2024 8:53 PM in response to Aliveinabrokenworld

Hi Aliveinabrokenworld,


My reply was to demonstrate the way that Numbers deals with Date & Time format. If you enter a time of day without a date, Numbers automatically adds the date when the entry was made.


Therefore, if Start and End times are entered on the actual days of Start and End, the dates will be correct and the Duration will be correct, even if the shift crosses midnight. However, if the Start and End times are both entered at the end of the shift, there will be a day missing. Thus the need for conditional +"1d" in my second formula.


It took me some time to get my head around the way that Numbers deals with Date & Time versus Duration. Not easy for someone coming from Excel!


BTW, If you enter a Date without a Time, Numbers automatically adds the Time as midnight.


Regards,

Ian.

Jan 5, 2024 8:37 PM in response to Aliveinabrokenworld

I have since added a formula to the Hours column so it would sum without an error field in the total:


E3=DURATION(,,IF(OR(C3="",D3=""),0,DUR2HOURS(D3−C3)))


Previously, Numbers didn't like zeros in the duration fields, hence I wasn't able to sum the column.


However, now I can't seem to figure out how to integrate that into this original formula I was using to solve the problem of anomalous shifts whose end times were < start times (like overnight shifts:)


IF(StartTime>EndTime,EndTime+1,EndTime)-StartTime


Stringing the second IF clause after the end of the first formula did not seem to work, and I tried many other variations in attempts to combine them.


Jan 6, 2024 6:04 PM in response to Badunit

Hey Badunit,


Yes I'm aware. I read on another thread that it was necessary to "trick" Numbers into treating the values as a decimal in order to process the equation, and then have it flip back to duration after. Wrong?


I did finally integrate the two equations I was struggling with before I got responses, and everything worked, but it's a beast (is there a term in Spreadsheet Land for unnecessarily long and hectic formulas?


DURATION(,,IF(OR(Start Time Jan 1="",End Time Jan 1=""),0,DUR2HOURS(IF(Start Time Jan 1>End Time Jan 1,End Time Jan 1+1,End Time Jan 1)−Start Time Jan 1) ))−Break Jan 1


Yours is a liiiiittle cleaner.


Jan 7, 2024 8:30 PM in response to Aliveinabrokenworld

Hi Julia,


I see replies with several different approaches, so I won't stir the pot. I will confine my reply to this question:


Aliveinabrokenworld wrote:

Hi Again Ian,

Right, it did take me a minute to see that, I wish there was a day to manually change the date but only have time showing.

Thanks again,

Julia


Yes, indeed. A cell formatted as Date & Time to show only the Time still contains the Date.

For example cell C5 where the shift has "crossed midnight".


Click twice on that cell. That cell will display the full contents of that cell and will place the cursor in the "text layer" of that cell. Now ready to edit the Day part of the Date.


However, in my Column E, the formula for Hours has already compensated by adding 1 Day if necessary, so there is no need to edit the times.


Regards,

Ian.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Error fields in Numbers timesheet / pay calculation table due to blank future hours fields.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.