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
BennyH
Regular Visitor

Generate a common parts table from either a single table or two identical tables

Hello All

 

Basically, we have a table of products names, product codes and all of their corresponding part numbers.

We want to have two sets of two slicers, one set for product one and another for product two so to compaore two products.

The set of slicers for the two selected products are products names and product codes.

We want to find all the common part numbers between the two products based on the product name and product codes.

Also, another table of not common parts.  So two tables, one of common parts and the other of unique numbers per product.

We have tried several ideas.  Even tried using two identical tables with one to many relationships for the product name, product codes and part numbes, still no success.  Have done tons of searching for solutions or anything at least close.  Even tried ChatGTP and Copliot with no luck.

 

So, the user would select Product One and a Product Code and the same for Product Two.

It would filter out two lists of Part Numbers and use something like intersect to find the common part numbers between the two products.  Then use the intersect to remove the common from the two list, leaving the unique or difference of part numbers.  Any help would be greatly appreciated.  Thank you

1 ACCEPTED SOLUTION

@BennyH 

This logic is different from the one in your first post. I have updated the DAX.

 

pls see the attachment below

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
johnt75
Super User
Super User

Create 2 tables to use in the slicers, like

Product 1 =
SUMMARIZE ( 'Table', 'Table'[Product Name], 'Table'[Product Code] )

Product 2 =
SUMMARIZE ( 'Table', 'Table'[Product Name], 'Table'[Product Code] )

Don't create any relationships from these tables, leave them disconnected. You can then create 2 measures like

Part is Common =
VAR SelectedPart =
    SELECTEDVALUE ( 'Table'[Part Number] )
VAR Parts1 =
    CALCULATETABLE (
        VALUES ( 'Table'[Part Number] ),
        TREATAS ( VALUES ( 'Product 1'[Product Code] ), 'Table'[Product Code] ),
        REMOVEFILTERS ( 'Table'[Part Number] )
    )
VAR Parts2 =
    CALCULATETABLE (
        VALUES ( 'Table'[Part Number] ),
        TREATAS ( VALUES ( 'Product 2'[Product Code] ), 'Table'[Product Code] ),
        REMOVEFILTERS ( 'Table'[Part Number] )
    )
VAR CommonParts =
    INTERSECT ( Parts1, Parts2 )
VAR Result =
    IF ( SelectedPart IN CommonParts, 1 )
RETURN
    Result

and

Part is Unique =
VAR SelectedPart =
    SELECTEDVALUE ( 'Table'[Part Number] )
VAR Parts1 =
    CALCULATETABLE (
        VALUES ( 'Table'[Part Number] ),
        TREATAS ( VALUES ( 'Product 1'[Product Code] ), 'Table'[Product Code] ),
        REMOVEFILTERS ( 'Table'[Part Number] )
    )
VAR Parts2 =
    CALCULATETABLE (
        VALUES ( 'Table'[Part Number] ),
        TREATAS ( VALUES ( 'Product 2'[Product Code] ), 'Table'[Product Code] ),
        REMOVEFILTERS ( 'Table'[Part Number] )
    )
VAR CommonParts =
    INTERSECT ( Parts1, Parts2 )
VAR AllParts =
    ALL ( 'Table'[Part Number] )
VAR UniqueParts =
    EXCEPT ( AllParts, CommonParts )
VAR Result =
    IF ( SelectedPart IN UniqueParts, 1 )
RETURN
    Result

You can then use these measures as filters on the table visuals, set to show only when the value is 1.

Thank you johnt75 for your resposne but it didn't seem to work.  I tried working it out with no success. 

ryan_mayu
Super User
Super User

could you pls provide some sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you ryan mayu for you reply,

 

This is sample source data table, I duplicated it for Product 2 table;

Product 1
Product NameProduct CodePart Number
A110001
A120150
A235120
A520150
B110001
B235120
B198456
B584562
C169500
C169500
C110001
C235120


Using slicers;

Product 1 slicers; Product Name = A & Product Code = 1,

Product 2 slicers; Product Name = B & Product Code = 1,
common part numbers expected results;

Product A & B Common Parts
Product NameProduct CodePart Number
A110001
B110001

 

same slicers selection, unique part numbers expected results is;

Product A & B Unique Parts
Product NameProduct CodePart Number
A120150
B198456

 

The results could just be the PART NUMBERS.

hope this helps, I'm still trying johnt75 reply code with no success yet.

as always any help is greatly appreciated.  I figured this woul dhave been a very simple task using FILTER to geenrate two tables of the two products part numebrs and then intersect the two for the common parts.  INTERSECT doesnt play nice with slicers. 

@BennyH 

pls see the attachment below

11.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




THANK YOU VERY MUCH ryan_muya works great.  I had to change it slightly but it worked great and thank you for providing within the context of an actaul power bi.  I'm trying to work through it to take it one step further.   return the part numbers that are in product B and not in product C.

 

same tables samples

Product 1
Product NameProduct CodePart Number
A110001
A120150
A235120
A520150
B110001
B235120
B198456
B584562
C169500
C169500
C110001
C235120

 

returns parts that are not in C that are in B

Product B & C Parts no part of C
Product NameProduct CodePart Number
B198456
B584562

we got part of it in your previous anwser but I believe we want to just filter out product C out of the results.  I tried that but without success, I ended up with an empty list of the second table of the non common parts.  thank you again

it's because you filter product A in one filter and filter product B in another filter. Then it will compare product A and product B. 

 

could you pls update the expected output? what value will you select in each filter and what's the expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for your reply.  selection is all Product B and all of Product C, expected output would be Product B - Product Codes 1 and 5, part Numbers 9845 and 84562 as shown in the image below.  This is filtering at the Product level and getting only the numbers that are exclsuive to product B.  Think of it as a next generation product and return parts are carry-over, excluding new parts for product C.

BennyH_0-1740718800436.png

 

Thank you again, I which the DAX filter and INTESECT and UNION and EXCEPT would work for this, I have the slicers filter each creating two tables but when I try to intersect the two thats where if fails.  After Googling that and discovering this is as designed we're here.  But what you provided defnitely work.

@BennyH 

This logic is different from the one in your first post. I have updated the DAX.

 

pls see the attachment below

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors
Top Kudoed Authors