cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Community Support

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

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.

3 REPLIES 3
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_id Customer_id Product_category 55640237 7263991 1 55640237 7263991 3 55640237 7263991 3 55640237 7263991 1 47810976 538974 2 46096606 765478 1
Community Support

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

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.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors