我正在Excel中建立排程工具。这包括具有开始和结束日期的任务列表,以及可以分配给每个任务的人员。
为了能够将这些数据输出到我们的预算系统中,我需要能够计算出给定月份内预定的员工时间百分比(所有任务的总和)。
我可以使用以下公式来计算工作人员在给定月份中在单个给定任务上可使用的时间:
=SUM(INDEX(WorkdayArrayMonCol,MATCH(B2,WorkdayArrayDateCol)):INDEX(WorkdayArrayFriCol,MATCH(C2,WorkdayArrayDateCol))*TRANSPOSE('Staff Profile'!$B$13:$B$17))
这对于单个任务非常有用,但是我需要在一系列任务中都可以使用的等效对象。
我的尝试目前看起来像这样:
=IFERROR(MMULT(MMULT(TRANSPOSE(ROW(INDEX(WorkdayArrayMonCol,MATCH(B2:B12,WorkdayArrayDateCol)):INDEX(WorkdayArrayFriCol,MATCH(C2:C12,WorkdayArrayDateCol)))^0),INDEX(WorkdayArrayMonCol,MATCH(B2:B12,WorkdayArrayDateCol)):INDEX(WorkdayArrayFriCol,MATCH(C2:C12,WorkdayArrayDateCol))),'Staff Profile'!$B$13:$B$17),0)
+ ctrl+ shift+enter
该公式使用索引/匹配来查找B2:B12 (task start date) and C2:C12 (task end date)
:
使用0 (0/01/1900)
如果任务是当月的范围内进行。这些搜索表WorkdayArray
包含6列,分别是“日期”,“星期一”,“星期二...”到“星期五”,然后返回日期范围的2D数组,其中包含要累加每个工作日在该范围内的值的值。这对于准确地捕捉公众假期是必要的。
然后将此2D数组乘以员工的工作可用性,即,在处'Staff Profile'!$B$13:$B$17
,这5个值中的每个值都是0> => 1,代表星期一至星期五。例如,如果他们在星期二工作半天,而在一周的其余时间工作了整天,则这5个单元格看起来像{1,0.5,1,1,1}
。
Using the technique posted here: How to use an array formula to return an array of sums in Excel I've managed to get it condensed down to a vector, but I can't get it to sum up the final total.
Using the formula above, the output is {8.5;4;2;2;0;0;0;0;0;0;1}
, which is the available workdays for each task, however my attempts to sum this resulting data using the MMULT
technique linked, SUMPRODUCT
, SUM
or SUMIF
keep resulting in the same data being returned:{8.5;4;2;2;0;0;0;0;0;0;1}
Since this calculation is going to be repeated for each financial month (y), across each staff member (x) it's not feasible to do a 3D excel representation by using (z) sheets as each of x, y, & z are impractically large. I'd rather not use VBA, and I'm close enough it seems like it should be possible using formulas.
Thanks very much!
Edit: A one-sheet version re Zac's request (same formula, adjusted references):
Single sheet version:
.
I've selected 11 cells to illustrate the array result (what I want is the formula to output the sum of these values, 17.5).
I used a different approach to get the required result, i.e. this array formula:
=SUM(COUNTIFS(B2:B12,"<="&Table1[Date],C2:C12,">="&Table1[Date])*MMULT(Table1[[Monday]:[Friday]],P3:P7))
confirmed with CTRL+SHIFT+ENTER
The COUNTIFS
part gives you a vertical vector representing how many times each date appears in the column B and C date ranges and then the MMULT
part gives you another vertical vector with a value for each date based on the P3:P7
values
Those two vectors can then be multiplied and summed for the final result - 17.5 shown in P12
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句