Forum Discussion

Milestone's avatar
Milestone
Frequent Visitor
3 years ago

Power query get files from folder driving me crazy

Hello.

I built a "get files from folder" power query in/from my OneDrive personal 365.  But now I've transferred that file and folders to my OneDrive business 365 premium on the web.  And now can't figure out the folder path change in my M code.  And, Sharepoint Folder is not available in "Get Data" for me in my business 365 for some reason so I can't use that option.  I'm using a Dynamic Path in my workbook that works fine if I am using my personal 365 account, i.e. "C:" drive. M code shown below.  But how do i get the same functionality in a web based 365 business OneDrive location?  I've watched a ton of videos but nothing is working.  I would be so thankful if anyone can help me here.  Thank you in advance.

let
Source = Excel.CurrentWorkbook(){[Name="DynamicPath1.0"]}[Content],
Path = Source{0}[Dynamic Folder Path for Power Query Source],
GetFilesFromFolder = Folder.Files(Path),
#"Sorted Rows" = Table.Sort(GetFilesFromFolder,{{"Date created", Order.Descending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),
#"Reordered Columns" = Table.ReorderColumns(#"Added Index",{"Index", "Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
#"Split Column by Position" = Table.SplitColumn(#"Reordered Columns", "Name", Splitter.SplitTextByPositions({0, 4}, true), {"Name.1", "Name.2"}),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Position",{{"Name.1", type text}, {"Name.2", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Name.2"})
in
#"Removed Columns"

 

 

 

 

 

2 Replies