Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Calculated Column identifying customers that have purchased specific products

Hi everyone,

 

I need some help with hopefully a basic issue!

 

I have Customer IDs (sales[Customer_ID]) and all the products that those customers purchased, as well as the brand of those products(sales[Brand]). There are only two brands I'm interested in looking at, so for the purposes of this, lets say the data in sales[Brand] only has "Brand 1" and "Brand 2".

 

I need to create a calculated column that checks the customer's ID, and checks if they have at any point in time purchased both Brand 1 and Brand 2. Doesn't have to be on the same date or anything. I just need the output to be "Yes" if both brands appear against any particular customer ID.

 

So for example results should be:

Customer IDBrandDateNew Calc column
Joe-12345Brand 101/01/2018Yes
Bob-6234Brand 106/07/2018No
Joe-12345Brand 212/01/2018Yes
Anne-7894Brand 220/07/2018No
Anne-7894Brand 220/02/2018No

 

Thank you for any assistance!

6 Replies

  • Anonymous try this calculated column

     

    Both Brand = 
    VAR __bothBrands = 
    CALCULATE( 
        DISTINCTCOUNT( Brand[Brand] ),
        ALLEXCEPT( Brand, Brand[Customer ID], Brand[Brand]), 
        Brand[Brand] In {"Brand 1", "Brand 2" } 
    )
    RETURN
    IF( __bothBrands >= 2, "Yes", "No" )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks parry2k for the response!

      Apologies, I'm having a bit of difficulty making this work though. 

      I've uploaded a sample file here if that helps.

  • Hi,

    This calculated column formula works

    =if(CALCULATE(DISTINCTCOUNT(Data[Brand]),FILTER(Data,Data[Customer ID]=EARLIER(Data[Customer ID])))>1,"Yes","No")

    Hope this helps.