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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
mosman
Frequent Visitor

Dax Measure at least one product

I am trying to get a distinct count of my customer who purchase a specific product and show all the other product they purchased as well. I tried to put the product name in the filter, but that would not show the other products.

Customer Count = CALCULATE(DISTINCTCOUNT(CustomerKey),'Customers Products'[ProductName]'='Thigh Master'). when I show it in a table it show it like this: Customer Name Product Name
John Doe Thigh Master
but I would like to see: Customer Name Product Name
John Doe Thigh Master
John Doe Ab Roller
John Doe Ab Master

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

Hi @mosman ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a product name dimension table(DO NOT create any relationship with your fact table)

Products = VALUES('Table'[ProductName])

yingyinr_0-1647585314965.png

2. Create a measure as below to determine if the corresponding customer should be displayed

Flag = 
VAR _selproduct =
    ALLSELECTED ( 'Products'[ProductName] )
VAR _selcustomer =
    SELECTEDVALUE ( 'Table'[Customer Name] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Customer Name] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ProductName] IN _selproduct )
    )
RETURN
    IF ( _selcustomer IN _tab, 1, 0 )

3. Create a table visual and apply a filter on this visual with the condition(Flag is 1) just as below screenshot

yingyinr_1-1647585631884.png

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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @mosman ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a product name dimension table(DO NOT create any relationship with your fact table)

Products = VALUES('Table'[ProductName])

yingyinr_0-1647585314965.png

2. Create a measure as below to determine if the corresponding customer should be displayed

Flag = 
VAR _selproduct =
    ALLSELECTED ( 'Products'[ProductName] )
VAR _selcustomer =
    SELECTEDVALUE ( 'Table'[Customer Name] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Customer Name] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ProductName] IN _selproduct )
    )
RETURN
    IF ( _selcustomer IN _tab, 1, 0 )

3. Create a table visual and apply a filter on this visual with the condition(Flag is 1) just as below screenshot

yingyinr_1-1647585631884.png

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.
mosman
Frequent Visitor

any help?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Kudoed Authors