cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fernandes_20
Frequent Visitor

How to make relationship between tables by conditional?

Hello everyone,

I have two tables that I need to relate by columns (Ref, Start and End), but the beginning and end of both tables are different, I was wondering if there is any way to make the intersection between the two tables to be able to make the relationship.

 

Capturar.JPG

 

Model:
. The lines (XX_00072 0 4) and (XX_00072 4 6) report to the line (XX_00072 0 6.96) because the beginning or the end intersects.

. The lines (XX_00072 6 11) and (XX_00072 11 12) report to the line (XX_00072 6.96 13.61) because the beginning or the end intersects.

 

Any way to do this?

 

Dataset Table 1:

Spoiler
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZVG7DcVACNvl6hRgcp9sEimKsv8WD5PqxQUujAXYXFc7z8fMJtrWLGtv9/ZH7lnjS44s9y+bTAKEJkDUoBohdBBkI7gyRB1UhxwdvDoOoY+ELkM6h3RRd6qH3D3KpS2xmRTNaix4c5G9Xl4dUxuTGDoqapTm4BWEh+RGKnHpV1bFapIdKaIYRBmEPhjvh1f6uH8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ref = _t, Start = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Ref", type text}, {"Start", Int64.Type}, {"End", Int64.Type}})
in
#"Changed Type"

 

Dataset Table 2:

Spoiler
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZNLbsQwDEPvojUXjqP4c5MBBkXvf4tSljcNvRiIeYTjEaV8v/b5/JZSejVY4a9hNvvBP74Y7LrRrreXkHXCHzEXhNUH99tbDHYXjLe1GEuHq7cgzB1T7ksIeyr87S3GMtHlXEI22lHFTAjrDj6/zISwUXGJmZCVr5f+E8Jmxy13JmSAhe+fEmtSiquiSqebUtSCp4udNMTQ7BPGXBtkERKyMmgNalOK58JQO2mIeWh5U4rWMPR/JaVg5Hp4QVZGXtRNGmIemlowlpWD1g0OyG2NyCXpTSkicnEXjMpRS0ObUlQOW76rTSlu1yklZPXTvb7v9dOubxofYD/s7KYUzdH0dFKKzuVWO2mIeTqdlGL0dfrnDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ref = _t, Start = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Ref", type text}, {"Start", type number}, {"End", type number}})
in
#"Changed Type"

 

Note It is not possible to merge between the tables because table 1 has 300,000 rows and Table 2 has 4000 rows

1 ACCEPTED SOLUTION
yingyinr
Community Support
Community Support

Hi @Fernandes_20 ,

You can append these two tables as new query in Power Query Editor with following codes just as suggested by @VijayP :

let
    Source = Table.Combine({#"Table 1", #"Table 2"}),
    #"Sorted Rows" = Table.Sort(Source,{{"Start", Order.Ascending}})
in
    #"Sorted Rows"

yingyinr_0-1623403963326.png

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
yingyinr
Community Support
Community Support

Hi @Fernandes_20 ,

You can append these two tables as new query in Power Query Editor with following codes just as suggested by @VijayP :

let
    Source = Table.Combine({#"Table 1", #"Table 2"}),
    #"Sorted Rows" = Table.Sort(Source,{{"Start", Order.Ascending}})
in
    #"Sorted Rows"

yingyinr_0-1623403963326.png

Best Regards

Community Support Team _ Rena
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

VijayP
Super User
Super User

@Fernandes_20 

i think we cannot create relation ship between these tables as the ref column in both the tables is multiple times and other data is not matching.

only thing you can use Full outer and merget the tables!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!