Forum Discussion

Holly454's avatar
Holly454
Frequent Visitor
3 years ago
Solved

Power Query running through each connected file each time new step added

Hello all   I am using Power Query in Excel 365. I connected using Files From Folder to import 10 csv files, each approx 3000 rows, 20 columns.   In my Transform Sample File step, only very basic...
  • ams1's avatar
    ams1
    3 years ago

    Hi Holly454 

     

    Sorry for the late reply.

     

    I see, you've used the wizard to combine the files.

     

    Can you please try the old-fashioned way below:

     

     

    let
        Source = Folder.Files(REDACTED),
        #"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name"}),
        #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "CsvDocument", each Csv.Document([Content])),
        // try to standardize column names like this
        #"Added CsvDocumentStandardColumns" = Table.AddColumn(#"Added Custom", "CsvDocumentStandardColumns", each Table.RenameColumns([CsvDocument],{
            // add below all renames needed for all files
            {"Columnx", "AnotherColumnName"}, 
            {"ColumnY", "Something"}
            // ...
        // below will make sure you get no error case a rename does not apply
        }, MissingField.Ignore)) 
    in
        #"Added CsvDocumentStandardColumns"

     

     

    And then Expand...

     

    ...and then add all your subsequent steps.

     

    IF/when you notice performance problems, please paste here your new query based on my initial code.

     

    I edited my answer as I saw you have different column names... let's hope this works.

     

    Please mark this as answer if it helped.

  • Holly454's avatar
    Holly454
    3 years ago

    This worked beautifully - thank you so much!