'How to count networkdays in a subset of a date range with restrictions?
Demo workbook is here, now with formulas: https://docs.google.com/spreadsheets/d/1uj5P17iIesV6tEIwt00jUqJQdipxubk18CfV0uZshgU/edit?usp=sharing
This question is very similar to, but different from: Expand/explode a Google Sheets table with ticket open and close stats to show all tickets open each month .
I have a list of job openings (Inputs tab) that I need to track for monthly metrics. My metrics need to count the number of job openings that were open for <=10 business days and those that are open for >10 business days in each month, ignoring holidays.
Each monthly total needs to count the net work days for said month and for any prior month. However it can't count any days after the end of said month. Any opening that hasn't closed needs to be counted from opening day to today().
For example, a job opens 12/31/2020 and closes 1/14/2021. Even though that job is open only 10 work days in January, it's counted as >10 because of the 1 extra work day from prior months.
A job that opens 1/29/2021 and closes 3/1/2021 would count as <=10 days for January because there's only 1 work day; >10 for February because there are 21 total work days; and >10 for March because there are 22 work days.
On the Monthly Metrics tab in the demo workbook, I need a formula to make B8:D9 match the answers in B2:D3 using the data from the Inputs tab.
The formula I have in B8 for counting jobs in December open <=10 days is:
=if(EOMonth(B$7,0)<Today(),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="open", Inputs!$C$2:$C<=EOMonth(B$7,0), networkdays(Inputs!$C$2:$C,EOMonth(B$7,0))<=10))), (countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="open", Inputs!$C$2:$C<=EOMonth(B$7,0), networkdays(Inputs!$C$2:$C,today())<=10))))
+if(EOMonth(B$7,0)<Today(),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="closed", Inputs!$D$2:$D<=EOMonth(B$7,0), Inputs!$D$2:$D>=B$7, networkdays(Inputs!$C$2:$C,EOMonth(B$7,0))<=10))),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="closed", Inputs!$D$2:$D<=EOMonth(B$7,0), Inputs!$D$2:$D>=B$7, networkdays(Inputs!$C$2:$C,Inputs!$D$2:$D)<=10))))
The formula I have in B9 for counting jobs in December open >10 days is:
=if(EOMonth(B$7,0)<Today(),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="open", Inputs!$C$2:$C<=EOMonth(B$7,0), networkdays(Inputs!$C$2:$C,EOMonth(B$7,0))>10))), (countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="open", Inputs!$C$2:$C<=EOMonth(B$7,0), networkdays(Inputs!$C$2:$C,today())>10))))
+if(EOMonth(B$7,0)<Today(),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="closed", Inputs!$D$2:$D<=EOMonth(B$7,0), Inputs!$D$2:$D>=B$7, networkdays(Inputs!$C$2:$C,EOMonth(B$7,0))>10))),(countA(filter(Inputs!$A$2:$A,Inputs!$B$2:$B="closed", Inputs!$D$2:$D<=EOMonth(B$7,0), Inputs!$D$2:$D>=B$7, networkdays(Inputs!$C$2:$C,Inputs!$D$2:$D)>10))))
As you can see, The counts are way off, and I can't keep the logic straight in my head, or on paper, well enough to figure it out.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
