Forum Discussion
Intersection Problem
| CustomerName | Products |
| Mayank | OCEG2 |
| Mayank | BRT3 |
| Lithia | BRT3 |
| Lithia | JOG0 |
| Lithia | JHOT8 |
| Chrils | HGY7 |
| Shantanu | JOG0 |
| Jennifer | JOG0 |
| Jennifer | OCEG2 |
| Jennifer | JHOT8 |
| Jennifer | BRT3 |
| Jennifer | HGY7 |
HI, I'm not able to calculate the intersection in Power BI.
Problem- I have Customer name and Product name in one table as two different columns. If i click on customer name , lets say, mayank and jennifer (multiselect), then number of products should be visible which is common in both. In my example its should be 2 (as product OCEG2 and BRT3 are the product purchased by Mayank and jennifer both.
Plus i want to show the common product name also which is common in both.
Please help!
Thanks in advance
- Anonymous7 years ago
for Intersection, i guess this below measure also helpful:
IF (ISBLANK (CALCULATE(COUNTROWS (FILTER (SUMMARIZE (Cust_table,Cust_table[CUST_CODE],"ProductsBought", DISTINCTCOUNT ( Sales[SKU])),[ProductsBought] = COUNTROWS ( VALUES ( Sales[SKU] ) ))))),0,CALCULATE(COUNTROWS (FILTER (SUMMARIZE (Cust_table,Cust_table[CUST_CODE],"ProductsBought",DISTINCTCOUNT ( Sales[SKU])),[ProductsBought] = COUNTROWS ( VALUES ( Sales[SKU] ) )))))
10 Replies
- MariuszCommunity Champion
Hi Anonymous
Please try the below DAX expression.
Measure = VAR _names = ALLSELECTED( 'Table'[CustomerName] ) VAR _products = CALCULATE( COUNT( 'Table'[Products] ), _names ) RETURN IF( COUNTROWS( _names ) = _products, 1 )
I've also attached a file with the example in the use.
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.- AnonymousNot applicable
Hi,
I apologize for my mistake,
But i want to multiselect Product instead of Customer and see how many customer bought both Product (If two products selected in slicer).
Thanks!
- MariuszCommunity Champion
Hi Anonymous
Please try the below.
Measure 2 = VAR _products = ALLSELECTED( 'Table'[Products] ) VAR _names = ADDCOLUMNS( VALUES( 'Table'[CustomerName] ), "xxxx", CALCULATE( COUNTROWS( 'Table' ), _products ) ) RETURN COUNTROWS( FILTER( _names, COUNTROWS( _products ) = [xxxx] ) )Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.