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

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
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

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
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

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.
VijayP
Super User
Super User

@Anonymous 

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
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.