Function in numpers that shows a different result depending on the conditions

Good evening and happy new year. I would like your help for a result in Numpers.

I have a table with my weekly work schedule. The normal working hours are 8 hours so I subtract the longest hour from the shortest and I have the result which is 8 hours. However, there are also days when the hours become 10-12 so we have overtime. These appear in another cell. And in this case I subtract the total number of working hours with the number 8. The problem starts when I have a day off where the cell with the overtime writes -8 while it should show 0 or nothing. Can someone tell me how to do it?

Posted on Jan 17, 2025 8:37 AM

Reply
12 replies
Sort By: 

Jan 17, 2025 10:58 PM in response to Giannisgen

Hi Giannisgen,


Testing for days off



Formula in D2 (and fill down) is IF(OR(B2="",C2=""),DURATION(,,0,0),C2−B2)

If a cell in column B or C is blank (=""), then insert a Duration of ,,0,0 (no weeks, no days, zero hours, zero minutes)

Else insert C-B.



Formula in E2 (and fill down) is IF(D2≤DURATION(,,0,0),DURATION(,,0),D2−"8h")


Please call back with questions.

Regards,

Ian.

Reply

Jan 24, 2025 2:53 AM in response to Giannisgen

Hi


I am glad it works with semicolon (;) 🙂.

Now to fix those negative Durations when your shift crosses midnight. We need to add one day (+"1d")



Formula in E2 (and fill down) is IF(B2>C2,D2+"1d",D2)

If Start is greater than End, then add one day, else copy the value in D.

Formula in F2 is IF(E2>DURATION(0,0,8,0),E2−"8h",DURATION(0,days,0,0))


You can hide Column D and rename Column E.



Regards,

Ian.

Reply

Jan 17, 2025 4:47 PM in response to Giannisgen

In this other cell where you calculate the overtime, use the function IF.


For instance, if your calculation is (A1-8) where cell A1 is where you enter the work hours, the function should be:

IF(A1-8<0,0,A1-8)


So if (A1-8) is lower than 0, 0 will be returned, otherwise the calculation (A1-8) will be returned.

Reply

Jan 19, 2025 2:12 PM in response to Giannisgen

Hi Giannisgen,


It works here.

One difference I can see is that your times have leading zeroes (08:00) but I can't format for that. Mine are 8:00.

What happens if you format as 12 hour clock?


Another little problem: your shifts on Saturday and Sunday "cross midnight" and give a negative duration. We can fix that, but first let's get your table working.


Regards,

Ian.

Reply

Feb 4, 2025 7:43 AM in response to Yellowbox

Thank you very much to Yellowbox and 6x6 for their help, I managed to make my work calendar. The calendar was based on their advice and also partly on the numbers template calendar. In the numbers calendar we can change the year and months simply by clicking on the corresponding arrows in their cell. However, if someone writes a reminder under the cell in the free field, it will appear in all months, so we will have to copy and paste the calendar 12 times and I find this somewhat inconvenient.

So I was wondering if it is possible that along with the months that change, the note fields also change so that in the next month they are empty to write what we want and of course we can return to the previous month and see our notes.

Is this possible in Numpers?

Reply

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.

Function in numpers that shows a different result depending on the conditions

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