Forum Discussion

DebbieE's avatar
DebbieE
Icon for Community Champion rankCommunity Champion
3 years ago
Solved

Change Data Source from Local Desktop to Sharepoint (Folder only because I select files later)

I have spent a lot of time sorting out the data source (Folder) and making sure it doesnt add helper files because I want to go to the folder and select multiple files with the same structure

 

then bring them through with the file name

 

This is the start of the code

 

let
Source = Folder.Files("C:\Users\MyName\Company\Project\Dummy Data"),

#"Filtered Rows" = Table.SelectRows(Source, each Text.Contains([Name], "Project")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Name"}),

 

However, its the local folder and not the Sharepoint folder.

What I really want to do it change it to the Sharepoint folder structure as easily as possible

 

I had a look at another forum post but this was connecting to the actual file not just the folder. I tried this

 

Source = Folder.Files("https://Company.sharepoint.com/sites/Project/Shared Documents/General/Dummy Data/"),

 

But get the error The supplied folder path must be a valid absolute path.

 

Is there an easy way I can move this from the Local folder to the Sharepoint folder and then continue with all the other M code Steps I have to

Filter to the files required

bring through the data (without creating Helper Queries including the file name

  • I have sorted it

     

    Source = SharePoint.Files("https://Company.sharepoint.com/sites/Project/", [ApiVersion = 15]),

    //Filter to the correct folder
    #"Filtered Rows2" = Table.SelectRows(Source, each Text.Contains([Folder Path], "Dummy Data")),

    //Filter to the correct files
    #"Filtered Rows" = Table.SelectRows(#"Filtered Rows2", each Text.Contains([Name], "Project")),

    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Name"}),

     

    and then you can continue on with the code

1 Reply

  • DebbieE's avatar
    DebbieE
    Icon for Community Champion rankCommunity Champion

    I have sorted it

     

    Source = SharePoint.Files("https://Company.sharepoint.com/sites/Project/", [ApiVersion = 15]),

    //Filter to the correct folder
    #"Filtered Rows2" = Table.SelectRows(Source, each Text.Contains([Folder Path], "Dummy Data")),

    //Filter to the correct files
    #"Filtered Rows" = Table.SelectRows(#"Filtered Rows2", each Text.Contains([Name], "Project")),

    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Name"}),

     

    and then you can continue on with the code