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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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