cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper 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
Highlighted
Solution Sage
Solution Sage

Re: Another crossjoin question

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Power BI Desktop August 2020 Update

Power BI Desktop August 2020 Update

We have great updates this month! Click the link for the video with more info.

Top Solution Authors
Top Kudoed Authors