Forum Discussion

Money's avatar
Money
Icon for Helper I rankHelper I
3 years ago

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 

 

Table B

 

Output table 

 

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

  • 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"