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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Money
Helper I
Helper I

Assign a value [ID] based on the condition and same value [ID] should not assign again

Hi Team,Help me with the following situation 🙂

 

Match Conditions 3

1)There are two tables need to match from one ID to another ID based on the condition. In both table these two columns ( Line number and Track number ) are common to the tables.Table A is left outerjoin to table B ON condition is Line number and Track number.

2)Then creating calculated colum MP Range.

MP range is the range between two Mp's (Thor mp, Cwr Mp) so subracting Thor Mp - Cwr Mp = value (Mp range).

Creating Mp range To find the Loose Mp range for the match condition.

Loose Mp range = .15

MP range <= Loose range

3)Same Rail should match in both the table Thor rail = CWR Rail. if all the rails are diffrent then match with close joint

 

Table A 

Money_0-1679046911804.png

 

Table B

Money_1-1679046931840.png

 

Output table 

Money_2-1679046987417.png

 

Excepetion column based on written in python. but im new to power bi please help me out for the best match and exception column creation 

 

if missing = true 

return 'Missing'

else if 

createException

 

def createException(i, thorList, cwrMP, cwrRP):
mpSync = False
railSync = False

tight = 0.02

if abs(cwrMP - thorList[i].getMP()) <= tight:
mpSync = True
if cwrRP == thorList[i].getRP():  (eg right = right  or left = left)
railSync = True

if mpSync == True:
if railSync == True:
return 'No Exception'
else:
return 'Rail Out of Sync'
else:
if railSync == True:
return 'MP Out of Sync'
else:
return 'MP and Rail Out of Sync'

 

Data 

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


Help is appreciated from my heart 🙂

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

 

 

1 REPLY 1
lbendlin
Super User
Super User

Did you know you can merge on more than one column?

let
    Source = Table.NestedJoin(#"THOR Data", {"Line Segment", "Track Number"}, #"CWR Data", {"Line Segment", "Track Number"}, "CWR Data", JoinKind.FullOuter),
    #"Expanded CWR Data" = Table.ExpandTableColumn(Source, "CWR Data", {"CWR ID", "CWR MP", "CWR Rail"}, {"CWR ID", "CWR MP", "CWR Rail"})
in
    #"Expanded CWR Data"

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.