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
Alirezam
Helper V
Helper V

Merging multiple csv files as importing to Power Bi

Hi mates,

I have got multiple csv files to be imported to Power Bi. They all have the same number of rows but different columns hence, need to be merged and not appended. When using the Power Bi default, the data are combined (appended) which I do not need. I need the data to sit across (merging) and come up with the same number of rows at the end. Any indication of how can I do this when I am importing the data from the source?

Regards,

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @Alirezam 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

v-alq-msft
Community Support
Community Support

Hi, @Alirezam 

 

As is said in the document , if you use folder connector to combine files, it will append multiple files that have the same schema, combine them into a single logical table. I'd like to suggest you use 'Text/CSV' connector to connect to CSV files. Then you may go to 'Home' ribbon, click 'Merge Queries', set as below.

e1.PNG

 

Finally you may expand the column 'File2' to get the result.

e2.PNG

e3.PNG

 

Best Regards

Allan

 

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

 

amitchandak
Super User
Super User

@Alirezam , Append should work as you will have additional columns where the column name do not match.

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

https://www.youtube.com/watch?v=4fFL7Ok7Ovg

 

Dax : https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/

 

Prefer the option of merge in data transformation

Thanks,

My problem is not with the queries. My question was when you import the csv files. when you select the multiple csv files to import, the Combine option only append the files

lbendlin
Super User
Super User

Did you know that behind the scenes both Append and Merge are served by the same Table.Combine statement?

 

Just use Append and trust Power Query to sort out the columns. 

 

HOWEVER: for this to work the spelling of the column names has to be consistent. Remember that M code is case sensitive.

 

After the Table.Combine you want to use Table.SelectColumns  rather than Table.RemoveColumns, for hopefully obvious reasons.

Thanks for your reply.

When we use 'combine' as you suggested, the files get appended and not merged. The column names are not consistent and should not be because I need to have them next to each other and not on the top of each other. Look below please: if you use append C1 will be on the top of D3 which does not make sense.

 

File 1:

Date                      C1C2

4/12/2019

56
1/3/20191012

 

File 2:

Date                     D3D8

4/12/2019

46
1/3/2019310

 

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.