Forum Discussion
SharePoint.Contents - Expression Error - Policy & Templates Folder Missing
- 7 months ago
When you explain the issue, it’s important to clarify that Power BI does not use the SharePoint UI or navigation menu to find files. The SharePoint.Contents connector only accesses locations that exist as actual document libraries or folders in SharePoint's metadata.Although the “Policies & Templates” link is visible in the SharePoint UI, it is not currently set up as a physical library or folder in the site's metadata. This is why Power BI cannot access it.
It may help to ask your SharePoint Administrator to check where these files are stored and confirm if “Policies & Templates” is a real document library or simply a navigation link, custom view, or shortcut. If needed, they can update SharePoint so that this location is a standard document library or folder. Once it is set up this way, SharePoint.Contents will be able to access it properly.
Regards,
Microsoft Fabric Community Support Team.
Hi TotalAnonymous
Thank you for contacting the Microsoft Fabric community forum.
The issue isn't related to access changes or the folder being deleted. The error occurs because the query tries to select a row that doesn't exist at the referenced level in SharePoint.Contents.
In SharePoint Online, “Policies & Templates” is a folder inside the “Shared Documents” library, not a top‑level node. SharePoint.Contents returns the hierarchy as it exists in SharePoint. If the lookup is done at the wrong level (for example, at the site root instead of within the library), Power Query returns: Expression.Error: The key didn’t match any rows in the table.
Also, SharePoint.Contents requires an exact match on the Name column, including special characters like &. If the M code uses "Policies and Templates" or searches at the wrong level, the lookup will fail, even if the folder is visible in SharePoint.
To resolve this, update the M code to use explicit table filtering on SharePoint.Contents instead of direct row navigation.
let
Source = SharePoint.Contents(
" https://xxx.sharepoint.com/sites/xxxx",
[ApiVersion = 15]
),
SharedDocuments =
Source{[Name = "Shared Documents", ItemKind = "DocumentLibrary"]}[Content],
PoliciesAndTemplates =
SharedDocuments{[Name = "Policies & Templates", ItemKind = "Folder"]}[Content],
Marketing =
PoliciesAndTemplates{[Name = "Marketing", ItemKind = "Folder"]}[Content],
CoreOfTheCore =
Marketing{[Name = "Core of the Core", ItemKind = "Folder"]}[Content]
in
CoreOfTheCore
After updating the query to use table filtering, the refresh should work properly without needing to switch to SharePoint.Files.
I hope this information is helpful. If you have any further questions, please let us know. we can assist you further.
Best Regards.
Microsoft Fabric Community Support Team.
Hi v-karpurapud , I'm sorry I just reply this post due to the holiday.
Thank you for your help for this one! Really need your assist further 🙂
I'm facing this one
On top of that,
I can't find Policies and Templates inside of "Shared Documents"
FYI, the current Policies and Templates is somehow on the top of hierarchy but as you can see in the above screenshot, I can't find Policies and Templates
Before this issue happened, My M Code works properly. Thank you!