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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Correlation in Product Structure

Hello there,

 

I'm working on a model where I could look at the similarity between products through the product structure.

 

The product structure looks like this:

TopProductComponentPart
1234ABC1
1234BCD2
1234CDE3
1234AABC1
1234AEFG1

 

I would like to plot out a correlation matrix, like this

TopProduct12341234A
123410,5
1234A0,331

 

The answer in the correlation would be how many products in that part was also in the other part. --> Product 1234A had 1 similar product component as product 1234 had --> 1/3 

 

I hope I made the question clear. Anybody have ideas on how to do this kind of calculation?

 

Thanks in advance!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous - I did it like this:

Measure 2 = 
    VAR __T = MAX('Table (4)'[TopProduct])
    VAR __T1 = MAX('Table 2'[TopProduct])
    VAR __Parts = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T),"__Parts",[ComponentPart])
    VAR __Parts1 = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T1),"__Parts",[ComponentPart])
    VAR __In = INTERSECT(__Parts,__Parts1)
RETURN
    COUNTROWS(__In) / COUNTROWS(__Parts)

PBIX is attached below sig, you want Table (4) and Table 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@Anonymous - I did it like this:

Measure 2 = 
    VAR __T = MAX('Table (4)'[TopProduct])
    VAR __T1 = MAX('Table 2'[TopProduct])
    VAR __Parts = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T),"__Parts",[ComponentPart])
    VAR __Parts1 = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T1),"__Parts",[ComponentPart])
    VAR __In = INTERSECT(__Parts,__Parts1)
RETURN
    COUNTROWS(__In) / COUNTROWS(__Parts)

PBIX is attached below sig, you want Table (4) and Table 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Amazing! Thank you!

 

Need to understand the dax-code behind it still, but that did the trick! Thanks alot!

@Anonymous - Sure, the first two lines simply figure out where we are in the matrix getting the value in the row and the column. We then create two table variables that filter out the rows in our base fact table based upon the values we have for our row and column. We use SELECTCOLUMNS to just get the column we are interested in.

 

INTERSECT is the key, it returns the rows that are common between the first table and the last table. So then it is just dividing this by our count of rows.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous , refer if these can help

https://www.mssqltips.com/sqlservertip/5197/correlation-analysis-using-correlation-plot-in-power-bi-desktop/

https://www.youtube.com/watch?v=xbTNYoW116g

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors