矩阵值的总和,有条件的,具有无限行和列

Sum of matrix values, conditional, with infinite rows and columns

我有 2 个 sheet:"Planning" 和 "Utilization" (example)

计划:每周分配给项目的员工。有些项目没有固定但需要模拟(checkbox = true)。

利用率:显示每个员工每周的利用率。只有行:

a) Planning 中没有复选框!A2:A
b) 选中复选框的行
c) Planning!B2:B 中带有项目名称的行将被考虑。

我想在 Utilization!B2 中有一个公式来计算 Utilization!B2:E4 的总和。 Planning 中有无限行和列 sheet。

尝试:

=QUERY(QUERY({Planning!A:H}; 
 "select Col3,sum(Col5),sum(Col6),sum(Col7),sum(Col8) 
  where not Col1 = FALSE 
    and Col3 is not null 
  group by Col3"; 0); 
 "offset 1"; 0)


更新:

=ARRAYFORMULA(QUERY(QUERY({Planning!A:Z}; 
 "select Col3,"&
 TEXTJOIN(","; 1; IF(Planning!E1:1="";;"sum(Col"&COLUMN(E:Z)&")"))&" 
  where not Col1 = FALSE 
    and Col3 is not null  
  group by Col3"; 0); 
 "offset 1"; 0))

修复 'get' 错误:

=ARRAYFORMULA(QUERY(QUERY({Planning!A:D\Planning!E:Z*1}; 
 "select Col3,"&
 TEXTJOIN(","; 1; IF(Planning!E1:1="";;"sum(Col"&COLUMN(E:Z)&")"))&" 
  where not Col1 = FALSE 
    and Col3 is not null  
  group by Col3"; 0); 
 "offset 1"; 0))

对于无限行和列,我喜欢使用 OFFSET(),因此您可以在新选项卡的 A1 中尝试此公式。

=ARRAYFORMULA({QUERY(QUERY({Planning!A:D\N(OFFSET(Planning!E1;;;ROWS(Planning!E:E);COUNTA(Planning!E1:1)))};"select Col3, "&TEXTJOIN(",";TRUE;"SUM(Col"&SEQUENCE(COUNTA(Planning!E1:1);1;5)&")")&" where Col2 is not null group by Col3";0);"offset 1";0)})