简体   繁体   中英

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. Column A identifies the Customer, Column B the day that the customer made a purchase, and Column C the fruit that they purchased. I simply want an IF statement that indicates whether, if on any day, the specified customer purchased both Apples and Bananas. 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.

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. If you don't use Control + Shift + Enter it'll just come up with "NO" for every row.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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