Forum Discussion

OKgo's avatar
OKgo
Icon for Helper IV rankHelper IV
6 years ago
Solved

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

  • 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

  • OKgo's avatar
    OKgo
    6 years ago

    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

     

2 Replies

  • Jimmy801's avatar
    Jimmy801
    Icon for Community Champion rankCommunity 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

    • OKgo's avatar
      OKgo
      Icon for Helper IV rankHelper IV

      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