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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
jameshoneywill
Frequent Visitor

Buys product A and buys product B

Hi 

I have a nice bit of dax calculating how many customers buy A and B

Bought A AND B =
VAR ACust =
CALCULATETABLE(
    VALUES(fact_Sales[Company ID]),
    dim_product[Product] IN VALUES('Product A'[Product])
)
VAR BCust =
CALCULATETABLE(
    VALUES(fact_Sales[Company ID]),
    dim_product[Product] IN VALUES('Product B'[Product])
)
RETURN

COUNTROWS(INTERSECT(ACust,BCust))

The tables 'Product A' and 'Product B' are just duplicates of the dim_product table so users can have two slicers to pick which products they wish to combine. It's writen like this because I also have another DAX measure using Except instead of Intersect to show the customers buying A and not buying B, and I can combine the outputs on the same dashboard from the same slicers etc etc. 

What I want to do is add a matrix to the report showing the number of customers buying both, (Product A on the Y axis and Product B on the X). The issue I have is the dax obviously counts the customers where Product A = Product B i.e. total customers of Product A. and I would prefer this to be blank or failing that zero/0... is there something simple I can add to the code?

TIA

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Try using a graphical solution first, like a matrix or column chart visual. You may not need a DAX based solution.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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