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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
bvbull200
Helper III
Helper III

Join Two Columns to Single Attribute Table

I have two tables.  The first is a table that lists each sku number one time and has a number of attributes for each one.  The second is a table that lists each combination of a main sku with its accessory sku.  This is like listing a computer as the main sku number 5 times and in each row having a different peripheral sku number associated with it.  The two tables are like this:

Attribute Table:

SKUPart #Stocked?Price

Brand

710001LaptopY$500HP
740001LaptopN$400HP
780003LaptopY$600Dell
790006MouseY$20HP
830007MouseN$50Dell
760008KeyboardY$75HP
770007KeyboardY$65Dell

 

Accessories Table:

Main SKUAccessory SKUPriority
7100017900061
7100017600082
7400017900061
7400017600082
7800038300071
7800037700072

 

The attribute table is much wider and I may need to pull in a lot of attributes, but what I'm trying to do is have a way where I can use the attribute table to determin the part # and brand for each Main SKU and for each Accessory SKU.  Can this be done via a relationship or am I having to merge queries at a point?  The query merge is not appealing to me due to the size of the dataset (7MM+ rows on the accessory table and 4.8MM rows X 100 columns on the attribute table).

 

In my head, I end up with an matrix where the main sku is listed as the row with the accessory sku nested underneath it.  If you expand the main sku, you'd see the part # for both the main sku and the accessory sku, along with any other attribute I included, but perhaps this isn't feasible.

 

Looking forward to any suggestions on this challenge. 

 

Thank you for your help.

1 ACCEPTED SOLUTION

@bvbull200,

Try this non-ideal solution first with your big data. If it works, we will see if it can be idealized furhter. 🙂

The idea is:

1) You create an additional table with this code:

barritown_0-1689875229485.png

In plain text:

Accessories Extended = 
UNION ( Accessories, 
        ADDCOLUMNS ( SUMMARIZE ( Accessories, [Main SKU] ), "Accessory SKU", [Main SKU], "Priority", 0 ) )

2) Then you create a relationship:

barritown_1-1689875346481.png

3) Then - an hierarchy:

barritown_2-1689875569598.png

 

4) Then you create a set of measures like this one:

Part #_ = 
IF ( ISINSCOPE ( 'Accessories Extended'[Accessory SKU] ),
     MIN ( Attributes[Part #] ),
     BLANK () )

5) Then you add a matrix visual an populate it with the hierarchy and the measures:

barritown_3-1689875645862.png

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

View solution in original post

6 REPLIES 6
barritown
Super User
Super User

Hi @bvbull200,

Am I correct that you would like to assemble a matrix like the one below? 

barritown_0-1689873272645.png

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

This would be VERY good.  Ideal would be to have the top level show the attributes without having to expand, but I could start with this for sure.

Hi again,

Yesterday I couldn't share the PBIX file with this solution, but today I can. Here it is - https://www.dropbox.com/scl/fi/agoxk4579pfvzwpwaomwt/community-peripherals.pbix?rlkey=1nh6wj3z4wysjn...

@bvbull200,

Try this non-ideal solution first with your big data. If it works, we will see if it can be idealized furhter. 🙂

The idea is:

1) You create an additional table with this code:

barritown_0-1689875229485.png

In plain text:

Accessories Extended = 
UNION ( Accessories, 
        ADDCOLUMNS ( SUMMARIZE ( Accessories, [Main SKU] ), "Accessory SKU", [Main SKU], "Priority", 0 ) )

2) Then you create a relationship:

barritown_1-1689875346481.png

3) Then - an hierarchy:

barritown_2-1689875569598.png

 

4) Then you create a set of measures like this one:

Part #_ = 
IF ( ISINSCOPE ( 'Accessories Extended'[Accessory SKU] ),
     MIN ( Attributes[Part #] ),
     BLANK () )

5) Then you add a matrix visual an populate it with the hierarchy and the measures:

barritown_3-1689875645862.png

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

I have finally made it back from some time away from this project and implemented this solution.  It works as advertised.  My tables have a lot more attributes than in the example, so there is a little more work I'm doing to get this far, but I wanted to thank you for the help in getting me this far.  I came to accept the solution, but looks like the admins beat me to it.  Very sorry for the delay in responding.

 

Cheers and thank you again. 

@bvbull200

I'm glad that you're advancing, but if I remember correctly your ideal solution would include showing attributes for the top level as well. Try to enhance your measures like shown below. 

barritown_0-1691654841058.png

And in plain text for convenience:

Price_ = 
VAR CurrentMainSKU = MIN ( [Main SKU] )
RETURN
IF ( ISINSCOPE ( 'Accessories Extended'[Accessory SKU] ),
     MIN ( Attributes[Price] ),
     CALCULATE ( MIN ( Attributes[Price] ),'Accessories Extended'[Accessory SKU] = CurrentMainSKU ) )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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