Forum Discussion

Thulasiraman's avatar
Thulasiraman
Helper II
3 years ago

Combine files from folder

Hi 

 

I have more than 100 excel files in a Folder which I would like to combine throug Power query.  Most of the files have same number of columns (for example 8 columns) except few which have different number of columns (for example 10 columns, 15 columns ......).  While combining the files, power query takes only 8 columns as it is found in most of the files and omits the additional columns found in other files.

 

How to overcome this.  Your help is most appreciated.  Thanks in advance

 

6 Replies

  • Hi,

    You will find a brilliant solution in this video

    Combine Data from Multiple Excel Files with Inconsistent Column Names

    by Goodly

    https://youtu.be/0ZOY8is-bgY

    If this post is useful to help you to solve your issue consider giving the post a thumbs up and accepting it as a solution !

     

     

  • Hi serpiva64 

     

    Thanks for your reply.  Saw the video.  I think the video talks about different column names.  In my case, I don't have column names at all.  But different number of columns in each file.

    • jennratten's avatar
      jennratten
      Super User

      Is the expected result supposed to include the unknown columns?  If they are unknown, how are you using them in your project?  Or are you simply trying to combine the data from all files that contain the specific 8 columns and omit the other columns?

      • Thulasiraman's avatar
        Thulasiraman
        Helper II

        Hi jennratten 

         

        Thanks for pitching in.  Actually the excile files which I am referring are nothing but Sales Invoices generated in excel.  It is a standard format with 8 columns being used.  But sometimes the clerk uses additional columns for the reasons best known to him.  So it happens that some files contain more than 8 columns.

         

        I tried selecting the file with maximum columns as sample file while transforming and combining.  It worked.  But the problem for me to open all the files and see which file has max columns.

    • serpiva64's avatar
      serpiva64
      Solution Sage

      Hi,

      you can use something that is in that video.

      When you get your table with all the table of data

      if you expand you hard code the names of columns

      So next time you will not get columns if they increase.

      Instead if you use Table.Combine you make it dynamic and all columns will be recovered

      Click fx

      obtain this

      then modify it 

      = Table.Combine( #"Filtered Rows1"[Data])

      and it's done