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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
kferrone
Regular Visitor

Union thinks column numbers are different

I am trying to make a union between two of the same table. I am following a tutorial on how to make tables incrementally load: Incrementally Load tables.

First I import the original tables the default PowerBI way which imports every column into a table. On those tables you can right click and view the source query which I copied and pasted into a new table where I simply add a where clause to the end to narrow in on the new data.

Then I go to modeling in the ribbon and create a new table with a union like so: tbl_union = UNION('tbl_old_data','tbl_new_data').

The issue is sometimes the tables will Union together just fine, then others will complain the number of columns don't match up.
The error message: "Each table argument of 'UNION' must have the same number of columns."

Each table I did this to, I followed the same exact process. It is really weird only some tables get this error and others don't. I have a feeling the problem is due to some kind of type mismatch with a column from each table. I'm pretty sure the default import is importing some columns as a different type than when the data came from a query.

Can anyone help clarify what is wrong here?

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @kferrone,

 

If you can't ensure these columns will be changed, you can try to use SELECTCOLUMNS function to choose specific columns.

Merged Table= 
UNION(
SELECTCOLUMNS('Table1',"COLUMN1",[Column1],"COLUMN2",[Column2],...),
SELECTCOLUMNS('Table2',"COLUMN1",[Column1],"COLUMN2",[Column2],...),
SELECTCOLUMNS('Table3',"COLUMN1",[Column1],"COLUMN2",[Column2],...)
)

 

You can also try use Table.InsertRows(Power query) to merge there tables.

 

In addition, if above not help, can you please share some sample data to test?

 

Regards,

Xiaoxin SHeng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

I get this error even when using ADDCOLUMS to choose my colums from each table. Why does UNION think I don't have the same number of columns from each table? 

 

PBIUnionError.PNG

 

 

Thank you. This really helped:)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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