Power Query - Conversion to Custom Function

scott_od

New Member
Joined
Jan 25, 2016
Messages
27
Hi, I am looking for some help with converting my query to a custom function, in order to retrieve all files in a folder.
However I'm unsure which part of the code should be replaced with the path&name variables.

Code:
let GetFiles=(Path,Name) =>

let
      
    Source = SharePoint.Files("https://xxxyyy.sharepioint.com/teamname", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = "https://xxxyyy.sharepioint.com/teamname/library/folder/")),
    #"excelfile xlsx_https://https://xxxyyy.sharepioint.com/teamname/library/folder/" = #"Filtered Rows"{[Name="excelfile.xlsx",#"Folder Path"="https://xxxyyy.sharepioint.com/teamname/library/folder/"]}[Content],
    #"Imported Excel" = Excel.Workbook(#"excelfile xlsx_https://xxxyyy.sharepioint.com/teamname/library/folder/"),
    #"exceldocument_Sheet" = #"Imported Excel"{[Item="worksheetname",Kind="Sheet"]}[Data],
    GetDate = Record.Field(#"worksheetname"{8},"Column5"),
    GetName = Record.Field(#"worksheetname"{6},"Column3"),
    GetNumber = Record.Field(#"worksheetname"{7},"Column3"),
    Custom1 = #"worksheetname",
    #"Replaced blanks" = Table.ReplaceValue(Custom1,"",null,Replacer.ReplaceValue,{"Column2"}),
    #"Filtered null" = Table.SelectRows(#"Replaced blanks", each ([Column2] <> null)),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered null", [PromoteAllScalars=true]),
    #"Filtered duplicate headers" = Table.SelectRows(#"Promoted Headers", each ([Reference Number] <> "Reference Number")),
    #"Renamed Size" = Table.RenameColumns(#"Filtered duplicate headers",{{"Size", "20'"}}),
    #"Replaced nulls" = Table.ReplaceValue(#"Renamed Size",null,0,Replacer.ReplaceValue,{"20'", "40'"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Replaced container nulls",{"Outbound Reference", "Reference", "Gross Weight", "Weight MT", "20'", "40'"}),
    #"Add Date" = Table.AddColumn(#"Removed Other Columns", "Date", each GetDate),
    #"Add Name" = Table.AddColumn(#"Add Date", "Name", each GetName),
    #"Add Number" = Table.AddColumn(#"Add Name", "Number", each GetNumber)
in
    #"Add Number"

in GetFiles

thanks in advance for anybody who can help :)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,699
Messages
6,173,905
Members
452,536
Latest member
Chiz511

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top