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.
I'm trying to track bundles of products through a set to see how many customers have a specific set of products.
The data structure is as follows:
Customer | Product |
Customer 1 | iPhone |
Customer 1 | iPad |
Customer 1 | AirPods |
Customer 2 | iPhone |
Customer 2 | iPad |
Customer 3 | Airpods |
Customer 4 | Airpods |
Customer 4 | iPhone |
Could I write a DAX measure to determine how many distinct customers have the combination of at least an iPhone and AirPods?
Solved! Go to Solution.
Hi @KabirDhupelia ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create a product dimension table
2. Create a measure as below to judge which customer fulfill the conditions
Flag =
VAR _selproducts =
ALLSELECTED ( 'Products'[Product] )
VAR _selcustomer =
SELECTEDVALUE ( 'Table'[Customer] )
VAR _selcount =
COUNTROWS ( _selproducts )
VAR _custcount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Product] ),
FILTER (
'Table',
'Table'[Customer] = _selcustomer
&& 'Table'[Product] IN _selproducts
)
)
RETURN
IF ( _custcount >= _selcount, 1, 0 )
3. Create a table visual and apply the filter with the condition (Flag is 1)
If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @KabirDhupelia ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create a product dimension table
2. Create a measure as below to judge which customer fulfill the conditions
Flag =
VAR _selproducts =
ALLSELECTED ( 'Products'[Product] )
VAR _selcustomer =
SELECTEDVALUE ( 'Table'[Customer] )
VAR _selcount =
COUNTROWS ( _selproducts )
VAR _custcount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Product] ),
FILTER (
'Table',
'Table'[Customer] = _selcustomer
&& 'Table'[Product] IN _selproducts
)
)
RETURN
IF ( _custcount >= _selcount, 1, 0 )
3. Create a table visual and apply the filter with the condition (Flag is 1)
If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
I guess you already have something as Product ID or you can generate
Step1
Step2
Thanks! How would I do this if the bundle contained more than 2 products?
I can give a code to the Product IDs
You can add as many as products, it should give a unique value, in this case I need 4(1+3)
Thanks,
Ritesh
Please mark the answer if it helped you
Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users
Thanks! I will test this out later this morning but it should work, will mark as a solution if it does then. Thanks!
Sure, let me know if it won't work
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
105 | |
87 | |
74 | |
66 |
User | Count |
---|---|
124 | |
112 | |
96 | |
80 | |
72 |