Finding and adding together overlaps in dates from 2 different columns in excel

后端 未结 2 778
北荒
北荒 2020-12-21 15:44

I have 2 tables on my excel workbook. One to track tasks and one to track leave. I want to see the impact leave would have on each tasks (i.e. the total number of leave days

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 16:11

    I used this "array formula" in E2 confirmed with CTRL+SHIFT+ENTER and copied down

    =SUM((H$2:H$7=A2)*TEXT(NETWORKDAYS(IF(I$2:I$7>C2,I$2:I$7,C2),IF(J$2:J$7

    This checks that the Resource matches, and for all matching rows does a NETWORKDAYS calculation (which ignores weekends) within any overlapping date periods between leaves and tasks.

    Where there is no overlap a negative value is returned so TEXT function is used to convert the negatives to zeroes.

    SUM function sums the resulting array to give you the required total - see screenshot

    If you want to allow blanks in the "leaves" end date field then you can use this adjusted version which will assume end date is today

    =SUM((H$2:H$7=A2)*TEXT(NETWORKDAYS(IF(I$2:I$7>C2,I$2:I$7,C2),IF(IF(J$2:J$7="",TODAY(),J$2:J$7)

    ...or you can replace the two instances of TODAY() with another date or cell reference containing a date

提交回复
热议问题