Excel - (数组公式)对多个有差异的条件求和 [英] Excel - (Array Formula) Sum IF Multiple Criteria with a Difference

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

问题描述

我需要了解如何(通过数组公式)根据多个条件总结结果.我知道有很多关于这个主题的问题已经得到解答,但我的似乎有所不同,因此就我所知,给出的解决方案已经不起作用.

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.

例如,请参见下表.我想要做的是在同一天没有类型 C 的类型 A 的所有 Val 求和.(即第 5 天和第 7 天)

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

推荐答案

J2 中的 1 元胞数组公式为:

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)))

为了了解发生了什么,我使用辅助列创建了 I2 公式._S1"、_S2"和_S3"是标题下方的命名范围.

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 为正则式

=SUMPRODUCT(_S1,_S3)

_S1 是数组公式

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

在这里,我只是返回A"类型的值和其他所有内容的零.

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

_S2 是数组公式

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

在这里,我创建了一个包含天数的范围,其中我有一个C"和一些额外的 FALSE.

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

_S3 是数组公式

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

在这里,我尝试将 A 列中的一天与范围 _S2 中的C 天"进行匹配.如果有匹配,我返回 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 - (数组公式)对多个有差异的条件求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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