Forum

How to do left join...
 
Notifications
Clear all

How to do left join and retain values from first table

4 Posts
2 Users
0 Reactions
145 Views
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Guys,

i have 2 tables and i am doing join like here:

1. Source Table

Topology Tier Function VolumeID ComponentInstance
Topo1 Tier1 Func1 1 2
Topo1 Tier1 Funct2 1 2
Topo2 Tier2 Funct3 5 5

2. Left join table (i want to get Function from here):

Topology Tier Function
Topo1 Tier1 Func1
Topo1 Tier1 Funct2
Topo1 Tier1 Funct3
Topo2 Tier2 Funct6

 

And what i want to achevie is:

Topology Tier Function VolumeID ComponentInstance
Topo1 Tier1 Func1 1 2
Topo1 Tier1 Funct2 1 2
Topo1 Tier1 Funct3 1 2
Topo2 Tier2 Funct3 5 5
Topo2 Tier2 Funct6 5 5

 

The Key is : Topology&Tier columns for join. 

So in result table you can see that for example Topo2 and Tier2 hkey has Funct3 and Funct4 left joined but VolumeID and ComponentInstance are the same like in Source Table. 

How can i do this in PQ? Please help,

in attachment please find workbook example. 

Jacek

 
Posted : 04/09/2020 1:37 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Jacek,

Try the attached query.  It works in the sense that it gives you the desired table, but relies on filling down missing values for:

Topo 1 : Tier 1 : Funct 3

Topo 2 : Tier 2 : Funct 6

and I don't know if this will always be the correct thing to do.

Regards

Phil

 
Posted : 04/09/2020 8:50 pm
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Philip this is awesome!!!

Thank you you helped so much!

 
Posted : 05/09/2020 3:01 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

no worries 🙂

 
Posted : 05/09/2020 9:10 am
Share: