Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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.
I want to achieve the following output:
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.
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?
@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.