Forum Discussion

RobGer's avatar
RobGer
Frequent Visitor
2 years ago

Rename Columns in Sample File Dinamically

Dear Colleagues,

 

I need to append together several excel files on a quarterly basis. The Date is structured the same way (4 columns, first the product, then one column for each month of the quarter, example: january, february, march, and then a total). The Problem I have, and why I can't just combine the files, is that the product column is named in some other way for each file.

I have extensively searched for a solution, but can't seem to find it on my own.

 

The files look like this:

File A Example:

Product TypeJanuaryFebruaryMarchTotal
Abonnement55515
Blog1218535
Video156

12

 

 

File B Example:

Row TypeJanuaryFebruaryMarchTotal
Product A20304090
Product B5102035
Product C57820

 

Expected Result:

ItemJanuaryFebruaryMarchTotal
Abonnement55515
Blog1218535
Video156

12

Product A20304090
Product B5102035
Product C57820

 

Thanks in Advance for the help!

4 Replies

  • Hello, RobGer 

    let
        a = table_A,
        b = table_B,
        c_names = {"Item"} & List.Skip(Table.ColumnNames(a)),
        tbl = 
            Table.FromRows(
                List.Combine({Table.ToRows(a), Table.ToRows(b)}),
                c_names
            )
    in
        tbl
    • RobGer's avatar
      RobGer
      Frequent Visitor

      Hello AlienSx

      I use as source a Sharepoint Folder, where I upload all the files each quarter. Wenn I pull this Folder into Power Query and combine, I get an error (presumably because of the Sheet name, as it is auto generated by the software from where the data comes from). So instead of directly combining the content of all Excel Files (which I can't because of the sheet names), how could I combine the files, independently of sheet name?

       

       

      • AlienSx's avatar
        AlienSx
        Super User

        RobGer I don't work with Sharepoint, can't help you with that, sorry ((

  • RobGer if you just want to rename first column to "Item" then

    Table.RenameColumns(your_table, {List.First(Table.ColumnNames(your_table)), "Item"})