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
KabirDhupelia
Regular Visitor

If a column contains a list of values

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:

CustomerProduct
Customer 1iPhone
Customer 1iPad
Customer 1AirPods
Customer 2iPhone
Customer 2iPad
Customer 3Airpods
Customer 4Airpods
Customer 4iPhone

 

Could I write a DAX measure to determine how many distinct customers have the combination of at least an iPhone and AirPods? 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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

yingyinr_0-1660729575835.png

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)

yingyinr_1-1660729768764.png

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-yiruan-msft
Community Support
Community Support

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

yingyinr_0-1660729575835.png

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)

yingyinr_1-1660729768764.png

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ribisht17
Super User
Super User

@KabirDhupelia 

I guess you already have something as Product ID or you can generate 

 

 

Step1

Count_Like = CALCULATE(DISTINCTCOUNT(Like[Customer]),FILTER(ALLEXCEPT(Like,Like[Customer]), OR(MIN(Like[Product])="AirPods",MAX(Like[Product])="iPhone")))

 

Step2

Solution_Like = if( SUMX(ALLEXCEPT(Like,Like[Customer]),[Count_Like]) >= 2,1,0)
NOTE: Filter=1
 
 
ribisht17_0-1660218420886.png

 

 
Regards,
Ritesh

Thanks! How would I do this if the bundle contained more than 2 products? 

 

I can give a code to the Product IDs

 

Count_Like_2 = IF(CALCULATE(SUM(Like[Produt ID]),FILTER(ALLEXCEPT(Like,Like[Customer]),Like[Produt ID] IN {3,1}))=4,1,0)
 
and will get the answer
 
ribisht17_0-1660236633254.png

 

ribisht17_1-1660236794958.png

 

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

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.