Forum Discussion

UncleLewis's avatar
UncleLewis
Icon for Responsive Resident rankResponsive Resident
5 years ago
Solved

Combine Files From SharePoint Folder

Hi all, I am using Power Query in Excel to try to combine files in a folder on my Sharepoint. Initially, I uploaded csv files, but I kept getting error messages in in PQ when I tried to change th...
  • edhans's avatar
    edhans
    5 years ago

    So before you do the Combine operation, use the filters to filter out everything you do not need.

    For example, set the filter to only keep files that end in CSV. If there are stilll files there you don't want, then start filtering to keep only files with certian words in them.

    Then do the combine operation. Not only will this select a valid sample file, it will keep the entire thing from breaking. Even if this had selected the file you wanted first, it would have used that file as a template to transform your Timesheet file, which would have likely broken.

     

    One other thing you can do that I recommend. If your files are in one folder, use SharePoint.Contents().

    When you create a connection to SharePoint folders it uses the SharePoint.Files() function by default. In the formula bar for the SOURCE row, change it to say SharePoint.Contents("https://blahblahblah" [apiwhtever]) - just change Files to Contents. Case sensitive.

    Now you will browse by folder. Usually you click on Shared Documents table, then down to the folder you want. From there you can transform an entire folder.

     

    This is the best way when all files are in one folder. Much faster than SharePoint.Files performs.

    One caveat - if you navigate down to the wrong folder there is no way to go back up without manually editing the M code. Usually faster to just delete the NAVIGATION step and start over from Shared Documents.