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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Many to many relationship help

Hi everyone,

 

I have two table connected with many to many relationship 😞 

I need building_id from table 2 in table 1. Is it possible to get result like below.

 table 1 

IDInvoice_ID
1301004789970
1301005789970
1301006789970
1301007789970
1301008789970
1301009789970
1301010789970
1301011789970
1301012789970
1301013789970
1301014789970
1301015789970
1301016789970
1301017789970
1301018789970
1301019789970

 

Table 2:

invoice_idbuilding_id
7899705132
7899705133
7899705134
7899705135
7899705136
7899705137
7899705138
7899705139
7899705140
7899705141
7899705142
7899705143
7899705144
7899705146
7899705148

 

I want new column in table 1 with building id's like below

 

IDInvoice_IDbuilding_id
13010047899705132
13010057899705133
13010067899705134
13010077899705135
13010087899705136
13010097899705137
13010107899705138
13010117899705139
13010127899705140
13010137899705141
13010147899705142
13010157899705143
13010167899705144
13010177899705146
13010187899705148

 

4 REPLIES 4
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

As itchyeyeballs said above, table1[ID] will match to every row in table 2 .

 

When you create calculated column building_id _matched in table2 , return result showing picture below.

 

building_id _matched = CALCULATE(FIRSTNONBLANK(Table2[building_id],1),FILTER(ALLSELECTED(Table1),Table1[Invoice_ID]=Table2[invoice_id]))

 

2.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

itchyeyeballs
Impactful Individual
Impactful Individual

Its hard to figure out what you are trying to achieve from your description, you can do a many to many join in the data import phase rather than in the model if you just want to end up with a single table with duplicated rows for all the matches.

Anonymous
Not applicable

Hi @itchyeyeballs  This is the problem, I don't want duplicates row's. I understand if it's many to many join, I always gonna end up with duplicates but might be something there in DAX which could give me row's without duplicates. If you look at the table 3 in the bottom, it has no duplicate row that's my requirement.

Hi from your example:

 

 table 1 

IDInvoice_ID
1301004789970

 

will match to every row in table 2 if joined on invoice_id. how do you want to identify which rows to keep?

 

There is a summarize function in DAX that may be of use but without more context its hard to tell

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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