Forum Discussion
InternDD
Apr 13, 2023Copper Contributor
Complex Working-Day Calculation
I am interning for a pre-construction firm. I was tasked with creating an calculator they can use to quickly find how much a job will cost if they input things like hourly labor, number of guys, hour...
NikolinoDE
Apr 13, 2023Gold Contributor
Here is a possible example of how this approach could be implemented in Excel:
- Let’s say your table of data is in the range A2:C8, with column A representing the days of the week, column B representing the number of hours worked on each day, and column C representing whether or not work was performed on that day (1 for yes, 0 for no).
- In a separate cell, you could use the MATCH function to find the first day that work was performed. For example, you could enter the formula =MATCH(1,C2:C8,0) to find the first row in column C that contains a 1 (i.e., the first day that work was performed).
- In another cell, you could use the MATCH function again to find the last day that work was performed. This time, you would need to use a slightly more complex formula to search for the last non-zero value in column C. One way to do this is to use the formula =MAX(INDEX((C2:C8<>0)*(ROW(C2:C8)-ROW(C2)+1),)). This formula will return the row number of the last non-zero value in column C (i.e., the last day that work was performed).
- Once you have the row numbers of the first and last days that work was performed, you can use the COUNTIF function to count the number of non-working days between those two dates. For example, if the first day worked was in row 2 and the last day worked was in row 6, you could use the formula =COUNTIF(C3:C5,0) to count the number of non-working days between those two dates.
I hope this helps!
- InternDDApr 13, 2023Copper Contributor