Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 二维条件计算_Arrays_Google Sheets_Sum_Google Sheets Formula_Array Formulas - Fatal编程技术网

Arrays 二维条件计算

Arrays 二维条件计算,arrays,google-sheets,sum,google-sheets-formula,array-formulas,Arrays,Google Sheets,Sum,Google Sheets Formula,Array Formulas,我有一个,每个产品都有它的类(如果类是无限的,我更喜欢,但是我也可以使用预定义的类)和状态active/inactive。 我需要H5的阵列公式来填充黄色区域(仅限活性产品)。我尝试过将MMULT和Arrayformula结合使用,但运气不好,也许有人能帮我。你需要 将条件应用于所有行的数组公式 if语句来验证复选框是否已选中 对同一类的多个列求和 您可以这样做: 键入H5 =ARRAYFORMULA(如果(和(C$3=true;C$2=“A类”);C5:C8;0)+如果(和(D$3=tru

我有一个,每个产品都有它的类(如果类是无限的,我更喜欢,但是我也可以使用预定义的类)和状态active/inactive。
我需要H5的阵列公式来填充黄色区域(仅限活性产品)。我尝试过将MMULT和Arrayformula结合使用,但运气不好,也许有人能帮我。

你需要

  • 将条件应用于所有行的数组公式
  • if
    语句来验证复选框是否已选中
  • 对同一类的多个列求和
您可以这样做:

键入
H5

=ARRAYFORMULA(如果(和(C$3=true;C$2=“A类”);C5:C8;0)+如果(和(D$3=true;D$2=“A类”);D5:D8;0)+如果(和(E$3=true;E$2=“A类”);E5:E8;0)+如果(和(和(F$3=true;F$2=“A类”);F5:F8;0))

并进入
I5

=ARRAYFORMULA(如果(和(C$3=true;C$2=“B类”);C5:C8;0)+如果(和(D$3=true;D$2=“B类”);D5:D8;0)+如果(和(E$3=true;E$2=“B类”);E5:E8;0)+如果(和(和(F$3=true;F$2=“B类”);F5:F8;0))

=ARRAYFORMULA(MMULT(IF(($C2:$F2="Class A")*($C3:$F3=TRUE); 
 INDIRECT("C5:F"&COUNTA($A5:$A)+4)*1; 0); TRANSPOSE(SIGN($C5:$F5))))
B类:

=ARRAYFORMULA(MMULT(IF(($C2:$F2="Class B")*($C3:$F3=TRUE); 
 INDIRECT("C5:F"&COUNTA($A5:$A)+4)*1; 0); TRANSPOSE(SIGN($C5:$F5))))

若要使其不受限制,请删除F:


这里有另一种方法试图解决“无限列”问题。这个问题的困难来自数据的2D性质,因此一种方法是对数据进行标准化或反向透视,以便每个数据项有一行。有很多方法可以做到这一点,但我选择使用vlookup方法:

=ArrayFormula({sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A)),
vlookup(roundup(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),filter(Sheet10!A5:A,Sheet10!A5:A<>"")},2,false),
hlookup(mod(sequence(counta(Sheet10!C2:2)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C2:2)),{sequence(1,counta(Sheet10!C2:2),0);filter(Sheet10!C2:2,Sheet10!C2:2<>"")},2,false),
hlookup(mod(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3)),{sequence(1,counta(Sheet10!C3:3),0);filter(Sheet10!C3:3,Sheet10!C3:3<>"")},2,false),
vlookup(roundup(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),Sheet10!C5:index(Sheet10!C5:Z1000,counta(Sheet10!A5:A),counta(Sheet10!C3:3))},mod(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3))+2)
})
=ArrayFormula({序列(counta(Sheet10!C3:3)*counta(Sheet10!A5:A)),
vlookup(序列(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),filter(Sheet10!A5:A,Sheet10!A5:A“”),2,false),
hlookup(mod(sequence)(counta(Sheet10!C2:2)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C2:2)),{sequence(1,counta(Sheet10!C2:2),0);filter(Sheet10!C2:2,Sheet10!C2:2“”)},2,false),
hlookup(mod(sequence)(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3)),{sequence(1,counta(Sheet10!C3:3),0);filter(Sheet10!C3:3,Sheet10!C3'')},2,false),
vlookup(序列号:counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{序列号:counta(Sheet10!A5:A)),Sheet10!C5:index(Sheet10!C5:Z1000,counta(Sheet10!A5:A),counta(Sheet10!C3:3))},mod(序列号:counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3))+2)
})
这将为您提供:

一旦您获得了这些信息,将其包装在pivot查询中以提供所需的总数就相当简单了:

=ArrayFormula(query({sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A)),
vlookup(roundup(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),filter(Sheet10!A5:A,Sheet10!A5:A<>"")},2,false),
hlookup(mod(sequence(counta(Sheet10!C2:2)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C2:2)),{sequence(1,counta(Sheet10!C2:2),0);filter(Sheet10!C2:2,Sheet10!C2:2<>"")},2,false),
hlookup(mod(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3)),{sequence(1,counta(Sheet10!C3:3),0);filter(Sheet10!C3:3,Sheet10!C3:3<>"")},2,false),
vlookup(roundup(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),Sheet10!C5:index(Sheet10!C5:Z1000,counta(Sheet10!A5:A),counta(Sheet10!C3:3))},mod(sequence(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3))+2)
},"select Col2,sum(Col5) where Col4=TRUE group by Col2 pivot Col3 label Col2 'Date' format Col2 'dd-mmm-yyyy'"))
=ArrayFormula(查询({顺序(counta(Sheet10!C3:3)*counta(Sheet10!A5:A)),
vlookup(序列(counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{sequence(counta(Sheet10!A5:A)),filter(Sheet10!A5:A,Sheet10!A5:A“”),2,false),
hlookup(mod(sequence)(counta(Sheet10!C2:2)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C2:2)),{sequence(1,counta(Sheet10!C2:2),0);filter(Sheet10!C2:2,Sheet10!C2:2“”)},2,false),
hlookup(mod(sequence)(counta(Sheet10!C3:3)*counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3)),{sequence(1,counta(Sheet10!C3:3),0);filter(Sheet10!C3:3,Sheet10!C3'')},2,false),
vlookup(序列号:counta(Sheet10!C3:3)*counta(Sheet10!A5:A))/counta(Sheet10!C3:3),0),{序列号:counta(Sheet10!A5:A)),Sheet10!C5:index(Sheet10!C5:Z1000,counta(Sheet10!A5:A),counta(Sheet10!C3:3))},mod(序列号:counta(Sheet10!A5:A),1,0),counta(Sheet10!C3:3))+2)
},“选择Col2,sum(Col5),其中Col4=TRUE按Col2透视分组Col3标签Col2'Date'格式Col2'dd mmm yyyy'”)
这给了你


Thanx,它可以工作,但我忘了提到我需要无限的列和行。这就是为什么我把“…”放在G1和A9中。如果你用
C5:C
等替换
C5:C8
,那么无限行是很容易的,但是如果你想对H列和I列中的类求和,你想如何实现无限列呢?我可以使用有限的类(a类、B类、C类…),但我需要无限数量的产品。即使它是有限的,它将是30-40列左右。所以我可以限制结果列的数量,但是基本列应该是无限的。我提出了一个类似的公式:=数组公式(mmult(N(数组约束($C$5:$G*($C$3:$G$3=TRUE)*($C$2:$G$2=“a类”);匹配(2;1/($C$5:$C”“);列($C$5:$G$5));序列(列($C$5:$G$5);1)^0))