[英]SumIfs conditional array criteria
I have a simple formula like: IFERROR(SUM(SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],{"0001","0002","0003"})),0)
and it works.我有一个简单的公式,如:
IFERROR(SUM(SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],{"0001","0002","0003"})),0)
并且它有效。
But I want the {"0001","0002","0003"}
part to be different based on the value of a column so I change the formula to:但我希望
{"0001","0002","0003"}
部分根据列的值而不同,因此我将公式更改为:
IFERROR(SUM(SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],IF([@TYPE]="EHT",{"0001","0002","0005"},IF([@TYPE]="CT",{"0003","0004","0007"},"0010")))),0)
And it gives me values only based on the first array value.它仅根据第一个数组值给我值。 Example:
例子:
IF([@TYPE]="EHT",{"0001","0002","0005"} //Gives me sum of only where "0001" and ignores "0002","0005"
IF([@TYPE]="CT",{"0003","0004","0007"} //Gives me sum of only where "0003" and ignores "0004","0007"
I thought excel is converting the critera into text so I have played around with different methods like using char(34), different number of quotes, putting values in different cells and referencing but no help.我认为 excel 正在将标准转换为文本,所以我尝试了不同的方法,例如使用 char(34)、不同数量的引号、将值放在不同的单元格中并引用但没有帮助。 Any idea what I am missing?
知道我缺少什么吗?
Sample tables: TBL1:示例表:TBL1:
SUMCOLUMN ACTIVITY 5 0001 20 0002 50 0003 ... TBL2: TYPE TOTAL EHT SUMIFS GOES HERE CT SUMIFS GOES HERE OTHER SUMIFS GOES HERE
I don't know WHY it is doing that - it's very annoying. 我不知道为什么这么做-这很烦人。 But in your particular case would this work:
但是在您的特定情况下,这可以工作:
=IFERROR(SUM(
IF([@TYPE]="EHT",SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],{"0001","0002","0005"}),0),
IF([@TYPE]="CT",SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],",{"0003","0004","0007"}),0),
SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],"0010")
),0)
Since SUMIFS returns an array of results and you are summing them, instead of trying to make the criteria conditional make the whole SUMIFS conditional. 由于SUMIFS返回结果数组,并且您要对它们求和,而不是尝试使条件成为条件,而将整个SUMIFS作为条件。
I know this question is a bit old, but I recently had to do something very similar and I randomly came across this question. 我知道这个问题有点老,但是最近我不得不做一些非常相似的事情,所以我随机遇到了这个问题。
I tried your formula and it works perfectly fine when I Ctrl + Shift + Enter
the formula in. 我尝试了您的公式,当我
Ctrl + Shift + Enter
公式时,它可以很好地工作。
=IFERROR(SUM(
IF([@TYPE]="EHT",SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],{"0001","0002","0005"}),0),
IF([@TYPE]="CT",SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],",{"0003","0004","0007"}),0),
SUMIFS(TBL1[SUMCOLUMN],TBL1[ACTIVITY],"0010")
),0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.