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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
EHa
Helper I
Helper I

Left Joining Tables using Power Query / Measures

Hi All, Sorry for the simplicity of the question - I had a look through a few similar questions but couldn't find any solutions which helped me out.

I understand my tables are not of the easiest set up, but they need to stay in the current format to work with the rest of my report.

This is my simple example: 

Capture.PNG

 Put simply, I would like the name of the city , instead of the ID, when LevelOfDetail is Region. 

I can't just link up the two tables and use region instead of attribute , as I would also like the attribute column to show for the other levelofdetail values. My two first approaches were to 1) - create a measure with an if function which used the reference to find the city when levelofdetail is city, and just used the existing attribute when not. 2) - write a left join between the two tables in power query ( these two tables will be import from sql) , and then sort the tables to the correct form using the toolbars in power query.

I couldn't get either to work, so if anyone has the solyution, that would be greatly appreciated.

Thanks a lot,

EHa

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi  @EHa 

for your case, I suggest you create a new attribute column in table2 by this logic:

New Attribute = 
VAR _ID=IF('Table 2'[LevelofDetail]="Region",VALUE('Table 2'[Attribute])) RETURN
IF('Table 2'[LevelofDetail]="Region",LOOKUPVALUE('Table 1'[City],'Table 1'[ID],_ID),'Table 2'[Attribute])

Now when create a visual, use this new attribute.

9.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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-lili6-msft
Community Support
Community Support

hi  @EHa 

for your case, I suggest you create a new attribute column in table2 by this logic:

New Attribute = 
VAR _ID=IF('Table 2'[LevelofDetail]="Region",VALUE('Table 2'[Attribute])) RETURN
IF('Table 2'[LevelofDetail]="Region",LOOKUPVALUE('Table 1'[City],'Table 1'[ID],_ID),'Table 2'[Attribute])

Now when create a visual, use this new attribute.

9.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lin,

That's great, thanks a lot.

Appreciate the effort in remaking it too, very clear now.

Cheers,

EHa

@v-lili6-msft 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.