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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ATULSBHATT
New Member

Product Matrix with Count of Customers Who have bought More than 1 product

I have a base product table with Products and Customer IDs. I want to achieve cross product matrix which returns the count of customer IDs greater than 1. 

1.png

I want to achieve the following output:

2.png

Let's say one customer ID has bought product A and the same ID has bought product B, Then the count must be Zero. If 2 Customer IDs have bought products A and B, then the count must be 1 . 
If Count(Customer ID) who have purchased Product A and Product B = 3, Then I want 2 as my output.
If the above can be achieved using only 1 or 2 measures it would be helpful.

2 REPLIES 2
AlexisOlson
Super User
Super User

I don't fully understand the request. It seems like there are multiple things going on where sometimes you're counting multiple products per customer and sometimes multiple customers per product pair.

 

AA = 1 because there is one extra duplicated row: A,2.

AB = 0 = BA because there are no customers who bought A and B.

AC = 1 = CA because ____?

BB = 2 because there are two extra duplicated rows: B,3

BC = 0 = CB because ____?

CC = 0 because all C rows are distinct.

 

Can you fill in the blanks and clarify exactly what you're trying to count?

Greg_Deckler
Community Champion
Community Champion

@ATULSBHATT I'm not sure that I completely understand all of your rules but here is a start. First, create a disconnected table for use in your Columns field well like this:

Table 2 = DISTINCT(SELECTCOLUMNS('Table',"Product",[Product]))

Then a measure like this:

Measure = 
    VAR __ProductColumn = MAX('Table 2'[Product])
    VAR __ProductRow = MAX('Table'[Product])
    VAR __CountRows = SELECTCOLUMNS('Table',"__CustomerID",[Customer ID])
    VAR __CountColumns = SELECTCOLUMNS(FILTER(ALL('Table'),[Product] = __ProductColumn),"__CustomerID",[Customer ID])
    VAR __Table = INTERSECT(__CountRows, __CountColumns)
    VAR __Result = COUNTROWS(DISTINCT(__Table)) + 0
RETURN
    __Result

You could implement a SWITCH(TRUE()...) statement to implement your rules. See PBIX attached below signature.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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