Sub topic 9
Connecting to a SharePoint Online list
This chapter assumes you know the Power BI Desktop interface, can read a Power Query step, and understand tables, rows, columns, and data types. It covers reading a SharePoint Online list as a table. Files stored in document libraries are covered in the previous chapter.
When a list is the right source
A SharePoint list stores rows of structured data directly on the site, much like an Excel table. Users add items through a form or a grid view, and each column has a type such as text, choice, date, or person. Use the list connector when the data lives in a list. If the data lives in an Excel or CSV file in a library, use a file-based option instead.
Like the file connectors, the list connector loads data in Import mode. A refresh reads the list again and replaces the loaded rows.
Connect from Power BI Desktop
- Select Get data, then SharePoint Online List.
- Enter the site URL, for example
https://contoso.sharepoint.com/sites/Sales. Use the site address only. Do not paste the address of a list or view. - Choose the 2.0 (beta) or 1.0 implementation if asked. Version 2.0 is the default for new connections and the examples here use it.
- Sign in with an Organizational account when prompted. The account needs at least read access to the list.
- In the Navigator, tick the list and select Transform Data.
The Navigator shows every list and library on the site. Choose the list by its title.
The query behind the connection
The connector creates M code like this:
let
Source = SharePoint.Tables("https://contoso.sharepoint.com/sites/Sales", [ApiVersion = 15]),
Tasks = Source{[Title = "Tasks"]}[Items]
in
TasksSharePoint.Tables returns a table with one row per list on the site. The expression Source{[Title = "Tasks"]} selects the row whose Title is Tasks. The [Items] field then returns the list items as a table. ApiVersion = 15 selects the SharePoint 2013 and later REST interface, which Microsoft Entra ID sign-in supports.
Because the lookup uses the list title, renaming the list in SharePoint breaks the query. The step then fails with an error saying the key matched no rows.
Clean up the list columns
A list table usually has more columns than you want, including system fields such as ID, Created, Modified, and Author. Look through them and keep only what the report needs.
- Remove unneeded columns with Choose Columns. Fewer columns means less data to load.
- Expand record columns. Person, lookup, and managed metadata columns arrive as records. Select the expand icon in the header and choose the field you need, such as
TitleorEMail. Multi-value columns arrive as lists and need expanding to new rows. - Check data types. Date and number columns usually arrive typed. Confirm them, and set any that arrived as
Any.
let
Source = SharePoint.Tables("https://contoso.sharepoint.com/sites/Sales", [ApiVersion = 15]),
Tasks = Source{[Title = "Tasks"]}[Items],
Kept = Table.SelectColumns(Tasks, {"Title", "Status", "DueDate"}),
Typed = Table.TransformColumnTypes(Kept, {{"DueDate", type date}})
in
TypedCommon problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Navigator shows no lists | The URL points to a list or page instead of the site | Use the site root URL, such as `/sites/Sales` |
| Sign-in loop or access error | The account has no permission on the site | Ask the site owner for read access |
| A column shows as `Record` or `List` | Person, lookup, or multi-value field | Expand it from the column header |
| Step fails after a SharePoint change | The list was renamed, or a column was renamed or deleted | Update the title or column name in the step |
Check your understanding
Exercise
A colleague pastes https://contoso.sharepoint.com/sites/Sales/Lists/Tasks/AllItems.aspx into the SharePoint Online List dialog and the Navigator shows nothing useful. What should they enter, and which part of the M code then selects the Tasks list?
Show answer
They should enter the site address, https://contoso.sharepoint.com/sites/Sales. After that, Source{[Title = "Tasks"]}[Items] selects the list: the first part picks the row for the list titled Tasks from the table SharePoint.Tables returns, and [Items] returns that list's items as a table.