首页 文章

Excel:获取每个日期的平均任务长度

提问于
浏览
0

我有一些任务,包括开始和结束日期:
enter image description here

我想计算每天正在进行的活动工作以及每天活动任务的平均工作长度 . 目前的WIP我能够计算如B2公式所示:

enter image description here

但是,我如何用C2:C7的类似公式计算所有活动任务的平均工作长度? (我在上图中也提供了预期结果和原因)

以下是csv的示例(虽然将作为一个工作表导入):

Task,start date,end date,,,,,,,,,,,,,,,,,,
T1,25.06.2018,26.06.2018,,,,,,,,,,,,,,,,,,
T2,25.06.2018,25.06.2018,,,,,,,,,,,,,,,,,,
T3,26.06.2018,28.06.2018,,,,,,,,,,,,,,,,,,
T4,26.06.2018,27.06.2018,,,,,,,,,,,,,,,,,,
T5,26.06.2018,26.06.2018,,,,,,,,,,,,,,,,,,
T6,26.06.2018,28.06.2018,,,,,,,,,,,,,,,,,,
T7,27.06.2018,27.06.2018,,,,,,,,,,,,,,,,,,
T8,27.06.2018,29.06.2018,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,
,,,,Day,Tasks in progress,average active task length (eod),,expected result,,,,,,,,,,,,
,,,,24.06.2018,0,,,0,,,,,,,,,,,,
,,,,25.06.2018,1,,,1,  at the end of 25th 1 task was active and running for 1 day (T1),,,,,,,,,,,
,,,,26.06.2018,3,,,1,"  at the end of 26th 3 tasks were active and each running for 1 day (T3,T4 and T6)",,,,,,,,,,,
,,,,27.06.2018,3,,,1.66,"  at the end of 27th 3 tasks were active and running for: 2d (T3), 2d (T6) and 1d (T8)",,,,,,,,,,,
,,,,28.06.2018,1,,,2,  at the end of 28th 1 task was active and running for 2 days (T8),,,,,,,,,,,
,,,,29.06.2018,0,,,0,,,,,,,,,,,,

1 回答

  • 1

    你可以在B2中使用数组公式:

    =SUM(IF(Tasks!$B$2:$B$9<=A2;1;0)*IF(Tasks!$C$2:$C$9>=A2;1;0))
    

    并接受公式CTRL SHIFT ENTER

    编辑:C2公式未添加

    =AVERAGE(IF(IF(Tasks!$B$2:$B$9<=A2;1;0)*IF(Tasks!$C$2:$C$9>=A2;1;0)=1;Tasks!$C$2:$C$9-Tasks!$B$2:$B$9;""))
    

    并接受公式CTRL SHIFT ENTER

    EDIT2:协商后的C2公式

    =IFERROR(AVERAGE(IF(IF(Tasks!$B$2:$B$9<=A2;1;0)*IF(Tasks!$C$2:$C$9>A2;1;0)*IF((Tasks!$C$2:$C$9-Tasks!$B$2:$B$9)>0;1;0)=1;A2-Tasks!$B$2:$B$9+1;""));0)
    

    接受公式CTRL SHIFT ENTER

相关问题