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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BI_user2023
Frequent Visitor

get value of a column from another table which has a many to many relationship

Hi everyone,

 

BI_user2023_0-1693906058432.png

I have two tables connected in a many-to-many relationship. Their key might be the concatenation of the fields 'art_cod,' 'client_code,' and 'price.' I need to add a column in 't1' whose value is the nearest (the value of date in t2 must be after that of t1, and in case of multiple rows, it should take the min date) date in the 'date' column of 't2,' and the columns 'art_cod,' 'client_code,' and 'price' should match (or the key, which is their concatenation).

Thanks a lot!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BI_user2023 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

vtangjiemsft_0-1693968345002.png

(2) We can create a calculated column in table1.

date2 = CALCULATE(MIN('T2'[date]),FILTER('T2','T2'[art_cod]=EARLIER('T1'[art_cod])&& 'T2'[client_code]=EARLIER('T1'[client_code]) && 'T2'[price]=EARLIER(T1[price]) && 'T2'[date] >EARLIER('T1'[date])))

(3) Then the result is as follows.

vtangjiemsft_1-1693968393478.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @BI_user2023 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

vtangjiemsft_0-1693968345002.png

(2) We can create a calculated column in table1.

date2 = CALCULATE(MIN('T2'[date]),FILTER('T2','T2'[art_cod]=EARLIER('T1'[art_cod])&& 'T2'[client_code]=EARLIER('T1'[client_code]) && 'T2'[price]=EARLIER(T1[price]) && 'T2'[date] >EARLIER('T1'[date])))

(3) Then the result is as follows.

vtangjiemsft_1-1693968393478.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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