Sub topic 7
Choosing a SharePoint connection option
This chapter assumes you know the Power BI Desktop interface, can read a Power Query step list, and have already connected to a local Excel workbook and a CSV file. Here you decide which of the SharePoint connection options fits a given file or list. The next two chapters then cover the file and list connectors in detail.
Why the choice matters
SharePoint Online holds several kinds of data, and Power BI has a separate connector for each way of reaching them. The connector you pick decides four things:
- What you navigate: a list of files, a single file, or the items of a list.
- How the path is stored: a site URL, or a full file URL.
- Which credentials the Power BI service needs for refresh.
- Whether you need an on-premises data gateway. For SharePoint Online data you usually don't.
A wrong choice usually still loads data. The problems show up later, as slow refreshes, brittle paths, or a refresh that fails in the service.
The main options
| Option | Connector function | You supply | You get | Best for |
|---|---|---|---|---|
| SharePoint Folder | `SharePoint.Files` | Site URL | A table of every file on the site, with `Name`, `Folder Path`, `Content` | Many files, or files that get replaced or renamed |
| Web (file URL) | `Web.Contents` with `Excel.Workbook` or `Csv.Document` | Full URL to one file | The one file's content | A single, stable file |
| SharePoint Online List | `SharePoint.Tables` | Site URL | The items of a list, with typed columns | Data stored in a SharePoint list |
| Local sync folder | `Excel.Workbook(File.Contents(...))` | Path to a OneDrive-synced folder | The local copy of the file | Quick desktop tests only |
The first three are the main choices. The local sync folder works in Desktop, but the path points at one person's disk. A published report can't refresh from it without a gateway, and it breaks for colleagues. Avoid it for anything you publish.
Decision flow
Start from what the data is, then from how many files there are.
SharePoint Folder in practice
SharePoint Folder takes the site URL, not a document library path. It returns every file on the site, including files in all libraries and subfolders. You then pick the file you want by filtering the rows.
let
Source = SharePoint.Files("https://contoso.sharepoint.com/sites/Sales", [ApiVersion = 15]),
FileContent = Source{[Name = "Sales.xlsx", #"Folder Path" = "https://contoso.sharepoint.com/sites/Sales/Shared Documents/"]}[Content],
Workbook = Excel.Workbook(FileContent, true, true),
SalesTable = Workbook{[Item = "Sales", Kind = "Table"]}[Data]
in
SalesTableThree details in this query matter:
- The site URL stops at the site name. Don't paste a URL that includes
/Shared Documents/or a view such asForms/AllItems.aspx. - The row lookup uses both
NameandFolder Path. Two files with the same name can exist in different folders, and the folder path includes a trailing slash. [Content]is a binary value. You pass it toExcel.WorkbookorCsv.Document, exactly as you passedFile.Contents(...)for local files.
Because the connector lists the whole site, a large site can make the first load slow. Filter early on Folder Path, so Power Query doesn't carry thousands of file rows through later steps.
SharePoint Online List in practice
If the data lives in a list, such as a task tracker, use the list connector. It returns list items as a table, with column types that come from the list definition.
let
Source = SharePoint.Tables("https://contoso.sharepoint.com/sites/Sales", [ApiVersion = 15]),
Tasks = Source{[Title = "Tasks"]}[Items]
in
TasksChoose this connector when the list is the system of record. Don't export a list to Excel and then connect to the export. That adds a manual step and a stale copy.
Web connector with a file URL
When you need exactly one file and its URL won't change, you can copy the file's link and use the Web connector. This is the simplest route for a single workbook. It does tie the query to that exact URL. If someone renames or moves the file, the query fails. SharePoint Folder is more tolerant, because you can filter on name and folder and adjust the filter in one place.
Criteria for choosing
Work through these questions in order:
- Is the data in a list? Use the SharePoint Online List connector.
- Do you need more than one file, such as monthly exports with the same layout? Use SharePoint Folder, which also supports combining files later in this tutorial.
- Is it one file that rarely moves? The Web connector with the file URL is the simplest. SharePoint Folder is still fine and gives you more room to adapt.
- Will other people refresh or edit the report? Avoid any path that depends on your own machine.
Credentials and refresh
Each SharePoint connector asks for credentials the first time you use a site. In Desktop you normally choose Microsoft account (organizational account) and sign in. The same sign-in is later set on the dataset in the Power BI service.
Credentials are saved per data source, not per query. Power BI treats the site URL as the source. So two queries against https://contoso.sharepoint.com/sites/Sales share one credential entry, while a query against another site needs its own.
For SharePoint Online, the Power BI service connects over the internet, so scheduled refresh doesn't need a gateway. A local file path does need one. This difference is the main practical reason to move files to SharePoint. The credentials chapter and the refresh chapter cover this in full.
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| The connector shows files from other libraries | `SharePoint.Files` lists the whole site | Filter on `Folder Path` |
| "We couldn't find the file" after a rename | Row lookup uses the old `Name` | Update the filter, or filter on a pattern such as `Text.StartsWith` |
| Web connector returns HTML or a sign-in page | Sharing link used instead of the file URL | Use the direct file URL without query text |
| Query works in Desktop but fails in the service | Local sync path in the query | Switch to SharePoint Folder or the Web connector |
| Cannot find the list | Site URL points at a subsite or page | Use the site root URL of the site that holds the list |
Summary
SharePoint Folder is the flexible default for files. The Web connector fits one stable file. The list connector fits list data. Avoid local sync paths in anything you publish. All three SharePoint Online connectors refresh in the service without a gateway, provided the credentials are valid.
Exercise
Your team stores a new Excel workbook named Sales-2026-01.xlsx, Sales-2026-02.xlsx, and so on in a SharePoint library each month. You want one report that picks them all up and refreshes in the Power BI service without a gateway. Which connector do you choose, and what URL do you give it?
Show answer
Use SharePoint Folder (SharePoint.Files). Give it the site URL, for example https://contoso.sharepoint.com/sites/Sales, not the library path. Then filter the file list by Folder Path and name pattern, and combine the files. The Web connector would need one hard-coded URL per file, and a local sync path would need a gateway.
Exercise
A query uses SharePoint.Files and the row lookup {[Name = "Sales.xlsx"]} fails with an error about multiple matches or a missing row. Give two likely causes.
Show answer
A file named Sales.xlsx may exist in more than one folder, so the lookup needs the Folder Path field as well. Alternatively, the file may have been renamed or moved, so the Name no longer matches any row.