Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding unique between two groups

Could anyone please tell me how to write a formula for identifying all CustomerIDs who have different products or a change of product base on the below table?

Outcome: on Column C to show the CustomerIDs 1 and 3 that have different Products

enter image description here

like image 221
karweng Avatar asked Sep 08 '25 07:09

karweng


2 Answers

As mentioned by @Foxfire And Burns And Burns you can use Filter and Unique if you have O365. It would look like this:

=UNIQUE(FILTER(A2:A11,COUNTIFS(A2:A11,A2:A11,B2:B11,"<>"&B2:B11)<>0))

enter image description here

If you did not have O365, you could revert to a pull-down formula. If you entered it in D2, say, it would be:

=IFERROR(INDEX(A$2:A$11,MATCH(1,(COUNTIFS(A$2:A$11,A$2:A$11,B$2:B$11,"<>"&B$2:B$11)<>0)*(COUNTIF(D1:D$1,A$2:A$11)=0),0)),"")

entered as an array formula.

like image 172
Tom Sharpe Avatar answered Sep 10 '25 01:09

Tom Sharpe


enter image description here

My formula in column C is:

=COUNTIFS($A$2:$A$11;A2;$B$2:$B$11;B2)=COUNTIF$A$2:$A$11;A2)

This formula will return True/False if the Customer has bought the same product always or not. You are interested in those customer who bought different products so you want to filter by FALSE option in this case:

enter image description here

If you got E365 you got functions like UNIQUE and FILTER, so you could filter the range using formulas instead of manually.

like image 43
Foxfire And Burns And Burns Avatar answered Sep 10 '25 03:09

Foxfire And Burns And Burns