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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Add columns from one table to another table as null columns along with their data types

I have 2 tables viz., Table 1 & Table 2.

Table 1 has standard columns (shown in bold) with some extra columns `Manual col1, `Manual col2, `Manual col3 etc. 

WB Study ID
Commissioning Country
Project Name
Field Start Date
Study Delivery Date
Client
Local Amount
Local Currency
IBP
Finance Coordinator
Study Status
Manual col 1
Manual col 2
Manual col 3
 

Table 2 has only the standard columns (shown in bold):

WB Study ID
Commissioning Country
Project Name
Field Start Date
Study Delivery Date
Client
Local Amount
Local Currency
IBP
Finance Coordinator
Study Status

 

I want to add the extra columns from Table 1 to Table 2, as blank or null columns, but keeping their data types intact. This is so that i can later merge new or updated data in Table 2 to Table 1.

 

Is there a quicker way to do this, instead of writing 3 Table.AddColumn() ?

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can append an empty copy of Table1 to Table2 and it'll add the extra columns.

Table.Combine({Table2, Table.SelectRows(Table1, each false)})

 

To generate this step, go to your Table2 query and click Append Queries (Home tab) then select Table1.

AlexisOlson_0-1638570500184.png

Then replace Table1 in the generated M code with Table.SelectColumns(Table1, each false).

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

You can append an empty copy of Table1 to Table2 and it'll add the extra columns.

Table.Combine({Table2, Table.SelectRows(Table1, each false)})

 

To generate this step, go to your Table2 query and click Append Queries (Home tab) then select Table1.

AlexisOlson_0-1638570500184.png

Then replace Table1 in the generated M code with Table.SelectColumns(Table1, each false).

Anonymous
Not applicable

The problem is, table1 and table2 are not empty.

Why is that a problem? I just explained how to get an empty copy.

Anonymous
Not applicable

True. But it doesn't copy the Table1's data types, but changes all to Text.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors