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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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