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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Chris2016
Resolver I
Resolver I

Create new table based on columns from related tables keeping all the values in the columns

Hello,

I need help with the following issue:

I have two tables where the following columns exist:

TableA

CategoryProduct
ACars
BPlanes
CTrains
DBicycles



TableB

ProductsColor
CarsBlue
CarsGreen
Cars 
PlanesBlue
PlanesWhite
Planes 
TrainsBlue
TrainsBlack
Trains 



I need to create a new table that contains three columns from the two tables, where all the values of all the columns are kept, i.e.:

CategoryProductsColor
ACarsBlue
ACarsGreen
ACars 
BPlanesBlue
BPlanesWhite
BPlanes 
CTrainsBlue
CTrainsBlack
CTrains 
DBicycles 


Any help in achieving this is much appreciated.

Thanks!


1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Chris2016 

First create a relationship between table A and table b using the field products. Then create the following table to have the desired results as a table.

Fowmy_0-1703252926976.png

 

Fowmy_1-1703252956800.png

New Table = 
SELECTCOLUMNS(
	NATURALLEFTOUTERJOIN( TableA , TableB ),
	TableA[Category],
	TableA[Product],
	TableB[Color]
)

 





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Fowmy
Super User
Super User

@Chris2016 

First create a relationship between table A and table b using the field products. Then create the following table to have the desired results as a table.

Fowmy_0-1703252926976.png

 

Fowmy_1-1703252956800.png

New Table = 
SELECTCOLUMNS(
	NATURALLEFTOUTERJOIN( TableA , TableB ),
	TableA[Category],
	TableA[Product],
	TableB[Color]
)

 





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thanks a lot for your help, Fowmy.

I do have a relationship like you mentioned:

Chris2016_0-1703260310512.png

 While in my test pbix I have an error in the formula, the table is displayed as expected.

Chris2016_1-1703260415769.png

However, in my actual report I get this error:

Chris2016_2-1703260518336.png



The relationship I have between TableA and TableB is between the IDs of columns Product, but it is a many to many relationship. Is this what's effecting the NATURALLEFTOUTERJOIN function?


Thanks a lot!

@Chris2016 

Yes, Many to Many relationships will not work in this case. I am not sure what your are trying to achieve by mergeing these tables. However, please try to keep one to many relationship by having a relevent dimension table. 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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