Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
OKgo
Helper IV
Helper IV

Lean M for SharePoint connector to folders

I have a table on Excel user interface that contains folders / parameters / variables. This query:

let
    #"Source from Table Range" = Excel.CurrentWorkbook(){[Name="ParameterTable"]}[Content],
    Path = Folder.Files(#"Source from Table Range"{0}[Path])
in
    Path

returns something like

C:\Users\okgo\Company123\SharePointSite\Folder1 

Which I then refernce in sample files and other queries as the source

 

Can I elgantly use the same table and adjust the M in advanced editor to leverage the SharePoint connector?

http://Company123.sharepoint.com/SharePointSite/Folder1

2 ACCEPTED SOLUTIONS
Jimmy801
Community Champion
Community Champion

Hello

 

Yes, just add a new column in the Exceltable called Typ. Input Folder or Sharepoint. In M-language you can refer now to this new column with an if-statement like if [Type] = "Folder" then Folder.Files... else Sharepoint....

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

Thank you @Jimmy801  - that makes sense for the Excel table UI

 

Using Sharepoint.Contents I can navigate to the correct folder. However that creates many steps which would be annoying (or non value adding) to feedback into the Excel UI. Maybe I will just live with the hardcoding as it does solve the problem of not being user specific which is an improvement to C:\

 

let
Source = SharePoint.Contents("https://company123.sharepoint.com/SharePointSite/", [ApiVersion = 15]),
Project1 = Source{[Name="Project1"]}[Content],
Folder2 = Project1 [Name="_Study_Specific"]}[Content],
Customer3= Folder2 {[Name="Customer3"]}[Content],
Account4 = Customer3{[Name="Account4"]}[Content],
in
Account4

 

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello

 

Yes, just add a new column in the Exceltable called Typ. Input Folder or Sharepoint. In M-language you can refer now to this new column with an if-statement like if [Type] = "Folder" then Folder.Files... else Sharepoint....

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Thank you @Jimmy801  - that makes sense for the Excel table UI

 

Using Sharepoint.Contents I can navigate to the correct folder. However that creates many steps which would be annoying (or non value adding) to feedback into the Excel UI. Maybe I will just live with the hardcoding as it does solve the problem of not being user specific which is an improvement to C:\

 

let
Source = SharePoint.Contents("https://company123.sharepoint.com/SharePointSite/", [ApiVersion = 15]),
Project1 = Source{[Name="Project1"]}[Content],
Folder2 = Project1 [Name="_Study_Specific"]}[Content],
Customer3= Folder2 {[Name="Customer3"]}[Content],
Account4 = Customer3{[Name="Account4"]}[Content],
in
Account4

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.