Forum Discussion
connecting to sharepoint sub folder
Hi RichardTam , Edson_Cruz94 , Chrisjm15 , Noivilbo -
I had this same issue today and was able to resolve by manually combining files in Power Query Editor (as noted by others, the wizard does not seem to include this functionality). Sharing the steps that worked for me below.
To add a SharePoint folder as a new source:
- Click Get Data > SharePoint folder
- Enter the root of the SharePoint site (example: https://sharepoint.com/sites/site)
- Click Transform Data (ignore the long list of files)
- In the Power Query Editor, filter the Folder Path column to only include the desired folder (search for the folder name and select it). The table should now have one row for each file in the SharePoint folder.
- On the Home tab of Power Query Editor, click Combine Files. If this button is grayed out, try clicking on another query then come back to this one, and then it should be active. This will create the same parameters and helper queries created by the wizard when using a local folder.
- Continue transforming data as needed.
To convert an existing local folder path to a SharePoint folder path without redoing the queries:
- Open Power Query Editor and select the Source (first step) of the primary query (NOT the helper query).
- Change Source path from = Folder.Files("C:\Users\path\data\") to = SharePoint.Files("https://site.com/sites/site", [ApiVersion = 15]). If this string does not work, you can find out what your string should be by creating a test connection to a SharePoint folder using the steps above, then copying the string that is generated to all queries that need to be moved.
- Filter the Folder Path column to only include the desired folder (search for the folder name and select it). If it's not possible to filter for the unique folder directly (if many results are returned), select only one folder and manually edit the filter text in the text bar of Power Query Editor to point to the desired folder.
- Query should now refresh from SharePoint instead of from the local folder.
Sorry, I don't have screenshots to share since the data in my example is proprietary.
hi jer91899,
Correct, these are the current way to get data, problem is lets say: https://sharepoint.com/sites/site belongs to a department, the department has a lot of folders and files.
Power BI has to go to the site, and read every single item within that site directory, before continuing step 4 which is to filter down to the folder you want
Common sense would say you can go to the sub-folder of that site directly, but that is not possible right now.
Combine with the fact that load anything from sharepoint takes way longer than other means. It is literally refresh and forget. Refresh, and forget you are working on it.
- Anonymous3 years agoNot applicable
Ran into a similar issue where the solution I posted above wasn't working due to the load query failing.
The step-by-step approach to do this manually is outlined here https://learn.microsoft.com/en-us/power-query/custom-function, but in my case it was easier to create a temporary SharePoint site with a small number of files to build the query, and then go back and update the URL (set as a parameter) to point to the live site.