简体   繁体   English

Excel:如果函数按两列过滤表,并查看第三列是否具有多个唯一值

[英]Excel: If function that filters a table by two columns and sees if a third column has more than one unique value

I am trying to identify if a customer (customer A) purchased both Apples and Bananas on the same day based on a table of data. 我试图确定客户(客户A)是否在同一天根据数据表购买了苹果和香蕉。 Column A identifies the Customer, Column B the day that the customer made a purchase, and Column C the fruit that they purchased. A列表示客户,B列表示客户购买的日期,C列表示他们购买的水果。 I simply want an IF statement that indicates whether, if on any day, the specified customer purchased both Apples and Bananas. 我只想要一个IF声明,表明在任何一天,指定的客户是否同时购买了苹果和香蕉。 In other words, for a specified customer, I want an output cell to indicate if "Yes", there is a day on which the specified customer purchased apples and bananas, or "No" there wasn't. 换句话说,对于指定的客户,我想要一个输出单元格来指示“是”,指定的客户是否购买了苹果和香蕉,或者“否”没有。

Customer Date           Fruit Purchased
A        2016/09/08     Apples
B        2016/09/09     Apples
C        2016/08/10     Apples
A        2016/09/08     Bananas
B        2016/08/12     Bananas
C        2016/09/13     Bananas
A        2016/09/13     Apples

Given the above table, if I specify Customer A as my customer, the formula should indicate "Yes", as customer A purchased Apples and Bananas on 2016/09/08. 鉴于上表,如果我将客户A指定为我的客户,则公式应标明“是”,因为客户A在2016/09/08购买了苹果和香蕉。

D栏中的内容如下:

=IF(COUNTIFS(A:A,A2,B:B,B2,C:C,"Bananas")+COUNTIFS(A:A,A2,B:B,B2,C:C,"Apples")>=2,"Yes","No")

Using an "array formula" is probably the easiest way to do it: 使用“数组公式”可能是最简单的方法:

Enter the following an instead of just pressing enter, use Control + Shift + Enter. 输入以下内容而不是仅按Enter键,使用Control + Shift + Enter。 If you don't use Control + Shift + Enter it'll just come up with "NO" for every row. 如果你不使用Control + Shift + Enter它会为每一行提出“NO”。

=IF(SUM(IF(A$2:A$8=A2,IF(B$2:B$8=B2,IF(C$2:C$8=C2,1,1),0),0))>1,"YES","NO")

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

相关问题 Excel Pivot - 一列多个值 - Excel Pivot - more than one value a column 如果两列匹配并且第三列满足值,则Excel计数 - Excel count if two columns match and third column meets value Excel公式在两列中搜索一列中的唯一值,在另一列中搜索固定值 - Excel formula to search two columns for unique value in one column and fixed value in another 当一列中的条目少于另一列中的条目时,匹配两列 - Match two columns when one column has fewer entries than the other in Excel 比较两列并在Excel中填写第三列 - Compare two columns and fill in the third column in Excel Excel Function 在两列中计算给定值,如果该值在一列或两者中,则计算 - Excel Function to count a given value across two columns, where it counts if the value is in one column or both Excel Pivot表在行中具有多个平均值 - Excel Pivot table with more than one averaged value in rows 具有两列 + 最大第三列的数据透视表 - Pivot table with two columns + max third column 在Microsoft Excel 2013中搜索两列,并使用特定值设置第三列的值 - Search two columns in Microsoft excel 2013 and set the value of a third column with a specific value 比较两个Excel列A&B,并在一个单元格中添加A中不存在的条目的第三列C的数据 - Compare two Excel columns A&B and add in one cell the data of a third column C of the entries not present in A
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM