Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Alenth
Regular Visitor

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!

1 ACCEPTED SOLUTION

@Alenth file is attached.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

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.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@Alenth 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" )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

@Alenth file is attached.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Perfect! I can't thank you enough. Really appreciate the assistance.

@Alenth glad I could help. Cheers!!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.