Forum Discussion
SharePoint.Contents - Expression Error - Policy & Templates Folder Missing
Dear Community,
I hope you're doing well. I have a question regarding SharePoint Contents expression.
Somehow, we're experiencing an error today.
This kind of error tell us that the "Policies and Template" does not exist in the SharePoint.
I've checked in the preview that the Policies and Template folder does not exist.
This is my current M Code. As you can see, before the error today, the refresh process ran smoothly. When I develop the transformation step, The Policies and Templates folder still does exist in the Power Query preview and yesterday.
This is a snapshot of targeted folder in the current SharePoint. As you can see, I still can access the path from my end. Therefore, I think that maybe the access issue is not a root cause of this issue.
May I know if you have experienced the same like this? If so, could you please suggest me what's the root cause? Actually, I'm thinking to change the SharePoint Contents expression into SharePoint Files expression. However, I don't want to that because It will make the my refresh time slower.
Really appreciate your advice on this.
Thank you!
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.
10 Replies
- v-karpurapudCommunity Support
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.
- TotalAnonymousHelper III
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 oneOn 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!- v-karpurapudCommunity Support
This error happens because the path specified in your M code no longer matches the current hierarchy provided by SharePoint.Contents, which only lists actual document libraries and folders.If a folder or library is renamed, moved, or its structure changes in SharePoint, SharePoint.Contents won’t find the expected row, leading Power Query to show the error “The key didn’t match any rows in the table.”
In your situation, “Policies & Templates” is no longer available at the expected location in the metadata, even if it still appears in the SharePoint UI. The UI may display navigation items that don’t always match the physical storage structure.This is a result of a mismatch between the UI and the metadata, not a permissions or deletion issue.To resolve this, review the Source step in Power Query and check which containers SharePoint.Contents currently lists. Update your navigation path by choosing the correct folder or library based on the latest metadata. Once your query matches the current hierarchy, the refresh should work without needing to change to SharePoint.Files.
If you have any more questions, please let us know and we’ll be happy to help.
Regards,
Microsoft Fabric Community Support Team.
- Ray_MindsSolution Supplier
Answer :- Sometimes SharePoint metadata changes behind the scenes (e.g., internal IDs or library refresh), even if the folder looks accessible in the browser. This can break the navigation record in Power Query.
- Instead of relying on the folder name in the navigation step, try using the Path column from SharePoint.Files or SharePoint.Contents and filter by the full path. This makes the query resilient to renames.
- If the folder is intermittently missing in preview, it could be due to throttling or sync delays. Add retry mechanism via a parameterized query or refreshing after a short interval can resolve it.
- Check if the folder is part of a recently archived or moved document library. Even if the URL works, the API may not return it until indexing completes.
- If performance is a concern with SharePoint.Files, you can still use it but apply an early filter on the Folder Path column before expanding. This limits rows and keeps refresh time reasonable.
- Finally, confirm that your credentials are set to Organizational Account and not cached incorrectly. Re-authenticate if needed.
- Sometimes SharePoint metadata changes behind the scenes (e.g., internal IDs or library refresh), even if the folder looks accessible in the browser. This can break the navigation record in Power Query.
- v-karpurapudCommunity Support
Hi TotalAnonymous
I wanted to check if you’ve had a chance to review the information provided. If you have any further questions, please let us know. Has your issue been resolved? If not, please share more details so we can assist you further.
Thank You. - v-karpurapudCommunity Support
We have not received a response from you regarding the query and were following up to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank You.