简体   繁体   English

具有OR条件的索引匹配数组公式

[英]Index Match Array Formula with an OR condition

I have a data frame that has a list of tasks with a Primary worker and secondary worker attached to the tasks. 我有一个包含任务列表的数据框,其中有主要工作人员和辅助工作人员附加到任务。

eg, 例如,

**Job** | **Primary** | **Secondary**   
Sales | Bob | John  
Marketing | Jeff | Bob  
Management | Steve | John

My question is, how can I write an array formula to return a list of Jobs when Bob matches either Primary OR Secondary? 我的问题是,当Bob匹配Primary或​​Secondary时,如何编写一个数组公式以返回作业列表?

So far my formula works like this: 到目前为止,我的公式如下所示:

=(IF(ROWS(D$3:D3)<=$E$1,INDEX(Jobs!$A$2:$A$3,SMALL(OR(Jobs!$B$2:$B$3=$D$1,Jobs!$C$2:$C$3=$D$1,ROW(Jobs!$A$2:$A$3)-ROW(Jobs!$A$2)+1),ROWS(D$3:D3))),""))

...where D1 contains Bob's name and E1 contains a COUNTIFS() of the occurrences of his name in either column. ...其中D1包含Bob的名字,E1包含任一列中他的名字出现的COUNTIFS()

The answer I'm looking for in D3 and D4 respectively is "Sales, Marketing". 我分别在D3和D4中寻找的答案是“销售,市场营销”。

Let me know if you need any clarification! 让我知道您是否需要任何澄清!

The OR function doesn't play well in array formulas as it is already a form of array processing. OR函数在数组公式中不能很好地发挥作用,因为它已经是数组处理的一种形式。

Your formula is better as, 您的公式更好,

=IF(ROWS($3:3)<=$E$1,INDEX(Jobs!$A$1:$A$99, AGGREGATE(15, 6, ROW($1:$99)/SIGN((Jobs!$B$1:$B$99=$D$1)+(Jobs!$C$1:$C$99=$D$1)), ROWS($3:3))),"")

... or for pre-2010 as, ...或在2010年之前,

=IF(ROWS($3:3)<=$E$1,INDEX(Jobs!$A$1:$A$99, SMALL(INDEX(ROW($1:$99)+((Jobs!$B$1:$B$99<>$D$1)*(Jobs!$C$1:$C$99<>$D$1))*1E+99, , ), ROWS($3:3))),"")

These are both standard formulas that do NOT require Ctrl+Shift+Enter. 这些都是不需要Ctrl + Shift + Enter的标准公式。

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

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