Hello there,
Although this is predominatley a Power Query Question, the criteria are obtained from an Excel Sheet and the output placed on 1 Excel sheet.
I have some PQ code (Windows Excel 2016) that will load a single pre-specified CVS file into Excel as follows:
Excel Sheet1:
Excel Name (Cell contents found in in A1): FilePath = C:\Users\Public\Documents\Data\
Excel Name (Cell contents found in in A2): Filename = James1.csv
Power Query Code:
This works perfectly fine for just the 1 dynamically named file. Changing the filename in the Excel Sheet also changes the data dynamically.
However, I am a little lost when trying to use multiple pre-specified file names in the same manner using the excel sheet...
eg if the Filenames were "James1,csv", John2.csv", Andrew1,csv", etc... all in the same FilePath and all re-definable via the spreadsheet cells A3,A4,A5, etc...(ie not in the PQ code) and assuming the data within each CSV is consistant (ie same columns), what PQ code could be used ot load each one on the same sheet?
Is there a way to define filenames (plural) to automatically load them into 1 sheet using Power Query? (unable to use any macros due to security settings).
Thanks
Although this is predominatley a Power Query Question, the criteria are obtained from an Excel Sheet and the output placed on 1 Excel sheet.
I have some PQ code (Windows Excel 2016) that will load a single pre-specified CVS file into Excel as follows:
Excel Sheet1:
Excel Name (Cell contents found in in A1): FilePath = C:\Users\Public\Documents\Data\
Excel Name (Cell contents found in in A2): Filename = James1.csv
Power Query Code:
Power Query:
let
FilePath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1],
FileName = Excel.CurrentWorkbook(){[Name="FileName"]}[Content]{0}[Column1],
Source = Csv.Document(File.Contents(FilePath & FileName))
in
Source
This works perfectly fine for just the 1 dynamically named file. Changing the filename in the Excel Sheet also changes the data dynamically.
However, I am a little lost when trying to use multiple pre-specified file names in the same manner using the excel sheet...
eg if the Filenames were "James1,csv", John2.csv", Andrew1,csv", etc... all in the same FilePath and all re-definable via the spreadsheet cells A3,A4,A5, etc...(ie not in the PQ code) and assuming the data within each CSV is consistant (ie same columns), what PQ code could be used ot load each one on the same sheet?
Is there a way to define filenames (plural) to automatically load them into 1 sheet using Power Query? (unable to use any macros due to security settings).
Thanks
Last edited: