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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Money
Helper I
Helper I

Creating a new table with a calculated column by joining two tables depending on the match

Hi All,

 

I am trying to create a grid by joining two tables from two different data sources. One of IBM DB2 another of databricks. Unique ID Both the tables are Line Segment and Track Number.  From there, we compute the Exceptions column according to the common condition below.

 

Based on this condition have to match the two tables

 

1. Requires same LS & Track Number

Mp range = Thor mp - cwr mp

2. Defines a Tight MP range -0.01 to 0.03 was recommended

3. Defines a Loose MP range 0.1 to 0.2 was recommended

4. Preferred to match with same rail ( thor rail = cwr rail ) within the loose MP range, but would match with opposite rail if there was no other joint around

 

* Below mentioned 4 points are joining condition for the 2 tables.

* MP range is THOR MP - CWR MP = that difference should satisfy the Tight Mp range and Loose Mp range.

* 4th point describes Thor rail and cwr rail from the table.

 

Two Tables Matching Condition 

 

Money_0-1678256848978.png

 

Thor Data screenshot 

 

Money_1-1678258411828.png

 

CWR Data Screenshot

 

Money_2-1678258492683.png

 

Expected output screenshot 

 

Money_3-1678258610254.png

 

In the ablove shared expected output screenshot is the required output to get in the power bi report and Thor Id should match with the single CWR ID and its should not duplicate. exception column is derived from the definition shared by first image.

 

 

In the below link attached the sample Data of two tables (THOR table and CWR table ) in the excel sheet with required expected output. Needs to get the power Bi report similar to the output.xls file from joining the two table.

 

https://ln5.sync.com/dl/bd0dd0280/h2wb67uu-a676nb9f-hmakf6m9-3ymfkzeb 

 

@tamerj1  @amitchandak @Greg_Deckler @Arul @v-zhangti @PowerQuerryGuru @Ashish_Mathur 

Please do the needful, I am new to power bi. 

 

 

6 REPLIES 6
andhiii079845
Solution Sage
Solution Sage

The join via Line Segment and Track Number is not possible. You have duplicates in both tables. You need a unique value in both table. How should Power BI decide what belongs together? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@andhiii079845 In both the table that 2 columns are the only match column then thor table is the left table and we are using left outer join later we are doing some business logic calculation to avoid the duplicates but we are not getting expected result.  Sharing screenshot for your reference from actual data. red box are duplicates value. one Thor ID should match with one CWR ID.

 

Money_0-1678707551122.png

 

How should one Thor ID match one CWR ID? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Based on this condition

1. Requires same LS & Track Number

Mp range = Thor mp - cwr mp

2. Defines a Tight MP range -0.01 to 0.03 was recommended

3. Defines a Loose MP range 0.1 to 0.2 was recommended

4. Preferred to match with same rail ( thor rail = cwr rail ) within the loose MP range, but would match with opposite rail if there was no other joint around

andhiii079845
Solution Sage
Solution Sage

Do you try to merge the tables in Power Query Editor? Is this possible? 

https://support.microsoft.com/en-us/office/merge-queries-power-query-fd157620-5470-4c0f-b132-7ca2616...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@andhiii079845  We have implemented the merging option and next we are not able to achive that output result which is shared in the question above. 

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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