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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
datamodel
Advocate I
Advocate I

Another crossjoin question

In the following activity table, I would like to get a count of all products that interacted with eachother under activity types 7,8,and15.

 

CustomerIDProductIDActivityTypeID
1238887
1238888
12378915
45678887
456777715
456799915
45679998

 

(pivot on related table Product)

ProductProductInteractions(number of products interacted with across all customers)
8883(interacted with products 789 on customer 123, and 777 and 999 on customer 4567)
7772(interacted with products 888 on customer 4567 and 999 on customer 4567)
9992(interacted with products 777 on customer 4567 and 888 on customer 4567)
7891(interacted with products 888 on customer 123)

 

(pivot on related table Customer)

CustomerProductInteractions(number of products interacted for all customers)
1232(888 and 789 interacted with eachother)
45673(888, 777, and 999 interacted with eachother)

 

(pivot on related tables Customer and Product)

CustomerProductProductInteractions(number of products interacted with eachother at customer/product level)
1238881(1 interaction for 789)
1237891(1 interaction for 888)
45678882(1 interaction for 777 and 1 for 999)
45677772(1 interaction for 888 and 1 for 999)
45679992(1 interaction for 777 and 1 for 888)

 

1 REPLY 1
v-joesh-msft
Solution Sage
Solution Sage

Hi @datamodel ,

In order to achieve the effect you want, you need 3 measures:

1. pivot on related table Product

pivot on related table Product =
VAR _table =
    CALCULATETABLE ( VALUES ( 'Table'[CustomerID] ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ProductID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[CustomerID] IN _table )
    ) - 1

2. pivot on related table Customer

pivot on related table Customer =
CALCULATE ( DISTINCTCOUNT ( 'Table'[ProductID] ) )

3. pivot on related tables Customer and Product

pivot on related tables Customer and Product =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ProductID] ),
    FILTER (
        ALLSELECTED ( 'Table'[ProductID] ),
        'Table'[ProductID] <> MAX ( 'Table'[ProductID] )
    )
)

Results are as follows:

21.PNG

 

Here is a demo, please try it

https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ERhkafE6NNtLnzro0a...

 

Best Regards,

Community Support Team _ Joey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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