Excel - (数组公式)Sum IF有多个不同的标准 [英] Excel - (Array Formula) Sum IF Multiple Criteria with a Difference

查看:216
本文介绍了Excel - (数组公式)Sum IF有多个不同的标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解(通过数组公式)根据多个条件来总结结果。我知道有很多关于这个话题的问题已经回答了,但是我的看起来是不一样的,所以提供的解决方案已经不尽如人意了。



As一个例子,见下表。我想要做的是将所有类型A的Val总和在同一天没有C类。 (即第5天和第7天)

 日类型Val 
1 A 5
1 B 6
1 C 9
2 B 2
2 A 8
2 C 3
3 C 4
3 B 2
3 A 2
4 A 5
4 B 9
4 C 8
5 A 7
5 B 5
6 A 6
6 B 3
6 C 4
7 A 7
7 B 9


解决方案



J2中的单元格数组公式为:


$ b $ (A2:A20,IF(A2:A20& B2:B20 = A2:A20,IF2) A20&C,A2:A20),0)))

要了解发生了什么事已经使用帮助列创建了I2公式。 _S1,_S2和_S3在标题下面被命名为范围。



I2是正常公式

  = SUMPRODUCT(_S1,_S3)

_S1是数组公式

  =(B2:B20 =A)* C2:C20 

这里我只是返回类型A和其他所有零的值。



_S2是数组公式

  = IF(A2:A20& B2:B20 = A2:A20&C,A2:A20 )

这里我创建一个带有日期数字的范围,我有一个C和一些额外的FALSE



_S3是数组公式

  = ISERROR(MATCH(A2 :A20,_S2,0))* 1 

这里我尝试匹配一列从A到C-days范围_S2。如果有匹配我返回0,否则为1。


I need to understand how (via an array formula) to sum up results based on multiple criteria. I understand there are plenty of questions on this topic already answered but mine seems to be different so the solutions given already don't work to the best of my knowledge.

As an example, see the below table. What I am wanting to do is sum all of Val for Type A where there is no Type C on the same day. (ie day 5 & 7)

Day     Type    Val
1       A       5
1       B       6
1       C       9
2       B       2
2       A       8
2       C       3
3       C       4
3       B       2
3       A       2
4       A       5
4       B       9
4       C       8
5       A       7
5       B       5
6       A       6
6       B       3
6       C       4
7       A       7
7       B       9

解决方案

1 cell array formula in J2 is:

=SUM((B2:B20="A")*C2:C20*ISERROR(MATCH(A2:A20,IF(A2:A20&B2:B20=A2:A20&"C",A2:A20),0)))

And to understand what's happening I have created I2 formula using helper columns. "_S1", "_S2" and "_S3" are named ranges below the headers.

I2 is normal formula

=SUMPRODUCT(_S1,_S3)

_S1 is array formula

=(B2:B20="A")*C2:C20

Here I am just returning values for Type "A" and zeros for everything else.

_S2 is array formula

=IF(A2:A20&B2:B20=A2:A20&"C",A2:A20)

Here I am creating a range with day numbers where I have a "C" and some additional FALSEs.

_S3 is array formula

=ISERROR(MATCH(A2:A20,_S2,0))*1

Here I try to match a day from column A to 'C-days' from range _S2. If there is a match I return 0, otherwise 1.

这篇关于Excel - (数组公式)Sum IF有多个不同的标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆