Hy Mynda.
In the code you provided, the "source files" are hard coded. Is there any way to make this dynamic as well?
What I need is a query from a folder that contains a set of xlsx about 30 files. There is a folder for each month, for example 2101, 2102, 2103, 2104 and so on. So I need a query that dynamically takes the source.
I tried to do this by creating a parameter called SourceFile and using Text.From() but it is not working.
let
//Get Excel Files from a Folder
Path = Excel.CurrentWorkbook(){[Name="PathTable"]}[Content],
Source = Folder.Files(Text.Combine({Path[FolderPathColumn]{0} ,Text.From(SourceFile)},"")),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Content"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Custom", each Excel.Workbook([Content])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Content"})
in
#"Removed Columns"
in a Second try I copy the whole folderpath in the PathTable and instead SourceFile I put "" as follows:
Source = Folder.Files(Text.Combine({Path[Path]{0} ,""},"")),
it worked:) Now the question is. Is there a way to see the whole Name of the files when expanding the columns?
in my case the Problem is, that the file names have the following structure: PK_LK_20.xlsx
in step 2 source (see sample image below): I can see the file name as follows: PK_LK_20.xlsx
but in step 6 Expanded Custom (see sample image below): I just see PK for all the files name
In this way I am unable to see exactly which files I want to kepp or take out. It would be helpful to get the rest of the name after the underscore.
Do you have any suggestions?
I really appreciate your help.
Thanks in advance
Hi Maria,
In step 3, 'Remove Other Columns', make sure you keep the column that contains the file name.
Mynda
Thank you very much!! Mynda,
it worked!!