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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

Intersection of 2 Category

I have a transaction table and product category table.
Client buys multiple category product and I need to calculate the count of customer who purchased only type1 and type2 together minus the result of when these category are bought together along with third category

1 ACCEPTED SOLUTION

Hi @Anonymous 

You can refer to the following measure, the sample data is the same as yours

Measure =
VAR a =
    CALCULATETABLE (
        DISTINCT ( 'Table'[Customer_id] ),
        'Table'[Product_category] IN { 1, 2 }
    )
VAR b =
    CALCULATETABLE (
        DISTINCT ( 'Table'[Customer_id] ),
        'Table'[Product_category] = 3
    )
RETURN
    COUNTROWS ( EXCEPT ( a, b ) )

Output

vxinruzhumsft_0-1702367041653.png

Best Regards!

Yolo Zhu

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

3 REPLIES 3
vanessafvg
Super User
Super User

are you able to share some sample data in text format?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Transaction_idCustomer_idProduct_category
5564023772639911
5564023772639913
5564023772639913
5564023772639911
478109765389742
460966067654781

Hi @Anonymous 

You can refer to the following measure, the sample data is the same as yours

Measure =
VAR a =
    CALCULATETABLE (
        DISTINCT ( 'Table'[Customer_id] ),
        'Table'[Product_category] IN { 1, 2 }
    )
VAR b =
    CALCULATETABLE (
        DISTINCT ( 'Table'[Customer_id] ),
        'Table'[Product_category] = 3
    )
RETURN
    COUNTROWS ( EXCEPT ( a, b ) )

Output

vxinruzhumsft_0-1702367041653.png

Best Regards!

Yolo Zhu

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

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.