My formula isn't picking up single day entries for absence.

maxim642

Board Regular
Joined
Feb 4, 2021
Messages
91
Office Version
  1. 365
Platform
  1. MacOS
=MAX(0,NETWORKDAYS(MAX(S$1,$G18),MIN(DATE(YEAR(S$1),MONTH(S$1)+1,0),$H18)))

In columns G & H I have the start and end dates respectively for when someone is absent from work. Columns S:AD have dates in them (the start of every month, Jan-Dec 2021.

The above formula is picking up the work days in between the dates when there is more than one day in between, but instances where the person is off for only 1 day just result in a "0", e.g. 07/02/2021 (Start), 07/02/2021 (End).

Maybe I need to create a helper column?? Any help is greatly appreciated.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Sorry, I just picked that date at random. It was supposed to be a weekday. So, let's say 15th Nov 2021 as an example.
 
Upvote 0
With weekdays your formula gives me a result of 1 when the start and end date are the same.
 
Upvote 0
Hmm, you're correct. The formula is working as intended. I assumed because there were a lot of records with the same start/end date that weren't being picked up that the formula wasn't working. I didn't realise those are all weekends.

If I want to include weekends, what's the simplest way to amend the formula? Basically, what I don't want to use NEWORKDAYS, instead simply count all days?
 
Upvote 0
The safest way is to use networkdays.intl with a 7 day working week.
Excel Formula:
=MAX(0,NETWORKDAYS.INTL(MAX(S$1,$G18),MIN(EOMONTH(S$1,0)-1,$H18),"0000000"))
I've simplified the DATE(...) part a bit for you as well but your original way would still work with this formula.
 
Upvote 0
The safest way is to use networkdays.intl with a 7 day working week.
Excel Formula:
=MAX(0,NETWORKDAYS.INTL(MAX(S$1,$G18),MIN(EOMONTH(S$1,0)-1,$H18),"0000000"))
I've simplified the DATE(...) part a bit for you as well but your original way would still work with this formula.
Thank you for helping with this but it's still not showing the single records.

I've uploaded a screenshot of the formula and dates. For Feb-21 (which is 01/02/21) it should show 1.
 

Attachments

  • Absence.PNG
    Absence.PNG
    8.7 KB · Views: 8
Upvote 0
Thank you for helping with this but it's still not showing the single records.

I've uploaded a screenshot of the formula and dates. For Feb-21 (which is 01/02/21) it should show 1.
I also tried using your slightly amended formula but it still returned a zero.
 
Upvote 0
Part of the formula is missing, try using the one from my reply.
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,258
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top