简体   繁体   English

索引/符合三个标准

[英]Index/Match with three criteria

I have searched and searched and searched and searched, I can only find solutions for index/match with two criteria. 我搜索和搜索,搜索和搜索,我只能找到索引/匹配的解决方案,有两个标准。

does anyone have a solution for index/match with three criteria? 有没有人有三个标准的索引/匹配解决方案?

as a sample of my actual data, i would like to index/match the year, type and name to find the data in the month column 作为我的实际数据的示例,我想索引/匹配年份,类型和名称以查找月份列中的数据

在此输入图像描述

You can match an unlimited number of criteria by using SUMPRODUCT() to find the proper row: 您可以使用SUMPRODUCT()找到正确的行来匹配无限数量的条件:

=INDEX(D2:D9,SUMPRODUCT((A2:A9=2015)*(B2:B9="Revenue")*(C2:C9="Name 1")*ROW(2:9))-1)

在此输入图像描述

EDIT#1: 编辑#1:

Scott's comment is correct! 斯科特的评论是正确的! The advantagesof the SUMPRODUCT() approach is that it is not an array formula and can be expanded to handle many criteria. SUMPRODUCT()方法的优点是它不是数组公式,可以扩展以处理许多标准。 The disadvantage is that it will only work if there is 1 matching row. 缺点是它只有在有1个匹配行时才有效。

The use of SUMPRODUCT() is explained very well here: 这里很好地解释了SUMPRODUCT()的使用:

xlDynamic Paper xlDynamic Paper

If assuming your data starts in A1 ("Year") and goes to D15 ("????"), you can use this. 如果假设您的数据以A1(“年”)开始并进入D15(“????”),您可以使用它。 You bascically just add your criteria with & , then when doing the Match() regions, connect their respective ranges with & as well. 您基本上只需使用&添加标准,然后在执行Match()区域时,使用&连接各自的范围。

=Index(D2:D9,Match(A15&B15&C15,A2:A9&B2:B9&C2:C9,0))

and enter with CTRL+SHIFT+ENTER and make the references absolute (ie $D$2:$D$9 ), I just didn't to keep the formula a little easier to read. 并使用CTRL + SHIFT + ENTER输入并使参考绝对(即$D$2:$D$9 ),我只是不保持公式更容易阅读。

Because your question has numerical data, you can simply use SUMIFS. 因为您的问题有数字数据,所以您可以简单地使用SUMIFS。

SUMIFS provides the sum from a particular range [column D in this case], where any number of other ranges of the same size [the other columns, in this case] each match a particular criteria. SUMIFS提供来自特定范围的总和[在这种情况下为列D],其中任何数量的相同大小的其他范围[在这种情况下其他列]各自匹配特定标准。 For text results, one of the other recommended solutions will be needed. 对于文本结果,将需要其他推荐的解决方案之一。

In addition to being a little cleaner, this has the attribute [could be good or bad depending on your needs] that it will pick up multiple rows of data if multiples exist, and sum them all. 除了更清洁之外,它还具有[根据您的需要可能是好还是坏]的属性,如果存在倍数,它将获取多行数据,并将它们全部加起来。 If you expect unique rows, that's bad, because it won't warn you there are multiples. 如果你期望唯一的行,这很糟糕,因为它不会警告你有多个。

The formula in your case would be as follows [obviously, you should adjust the formulas to reference your ID cells, and pick up the appropriate columns]: 您的情况下的公式如下[显然,您应该调整公式以引用您的ID单元格,并选择适当的列]:

=SUMIFS(D:D,A:A,2015,B:B,"Revenue",C:C,"Name1"))

What this does is: 这样做是:

Sum column D, for each row where: (1) column A is the number 2015; 总和列D,对于每一行,其中:(1)列A是数字2015; (2) column B is the text "Revenue"; (2)B栏是“收入”; AND (3) column C is the word "Name1". AND(3)列C是单词“Name1”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM