Forum Discussion
ETL Options with files loop (powerquery or free?)
- 2 months ago
Hi icassiem,
You can do the looping in Power Query regardless of timestamps.
The query below will:
- Connect to a SharePoint site
- Find all CSV files
- Keep only files where the file name contains one of the keywords
- Combine all matching files into one table
- Add the source file name and source folder for audit purposes
Example
let SiteUrl = "https://yourtenant.sharepoint.com/sites/yoursite", Keywords = {"mature", "efficiency", "interna"}, Source = SharePoint.Files( SiteUrl, [ApiVersion = 15] ), FilterCsv = Table.SelectRows( Source, each Text.Lower([Extension]) = ".csv" ), FilterKeywords = Table.SelectRows( FilterCsv, each List.AnyTrue( List.Transform( Keywords, (k) => Text.Contains(Text.Lower([Name]), Text.Lower(k)) ) ) ), RemoveHiddenFiles = Table.SelectRows( FilterKeywords, each [Attributes]?[Hidden]? <> true ), TransformCsv = (FileContent as binary, FileName as text, FolderPath as text) as table => let Csv = Csv.Document( FileContent, [ Delimiter = ",", Encoding = 65001, QuoteStyle = QuoteStyle.Csv ] ), PromotedHeaders = Table.PromoteHeaders( Csv, [PromoteAllScalars = true] ), AddSourceFile = Table.AddColumn( PromotedHeaders, "SourceFile", each FileName, type text ), AddSourceFolder = Table.AddColumn( AddSourceFile, "SourceFolder", each FolderPath, type text ) in AddSourceFolder, AddData = Table.AddColumn( RemoveHiddenFiles, "Data", each TransformCsv([Content], [Name], [Folder Path]) ), Combined = if Table.RowCount(AddData) = 0 then #table({}, {}) else Table.Combine(AddData[Data]) in CombinedThe important part is this:
Keywords = {"mature", "efficiency", "interna"}This means the query will include files where the file name contains any of those words.
Examples that would be picked up:
202607_clientA_mature_export.csv clientB_efficiency_202607.csv timestamp_clientC_interna.csv
If you want separate outputs, for example one table for Mature and another for Efficiency, then create one query per keyword. But if all files should be appended into one table, the query above works.
Important: all files combined in the same query should have the same structure/columns.
And yes, you can definitly do this with powershell or Python, if you are want to do it that way, just ask we will figure out something.
And sorry if i misunderstand the problem above with PowerQuery looping.
Hi,
This isn't a crappy question at all—it's actually a very common situation when building an MVP before the full platform is available.
For the next 4–5 months, I'd keep the solution as simple as possible and avoid introducing another ETL tool unless there's a real need.
Power Query can absolutely handle this. A common approach is:
Save all monthly CSV exports into a single parent folder (including any client subfolders if needed).
In Power BI, use Get Data → Folder.
Use Combine Files to automatically append all CSVs that match your expected schema.
Keep the Source.Name and Folder Path columns so you can extract the client name and timestamp from the filename/folder if required.
If only the latest export per client should be included, Power Query can sort by timestamp and keep the latest file for each client before combining the data.
This approach is dynamic—each month, users simply drop the new CSVs into the folder and refresh the dataset. No need to manually merge files.
If you need a preprocessing step, PowerShell or a small Python script are also good free options, but I'd only go that route if:
The files have inconsistent schemas.
You need complex validation or cleansing before Power BI.
The volume becomes too large for comfortable Power Query refreshes.
Given your timeline, I'd recommend:
Now (MVP): Power BI + Power Query Folder connector.
November (Fabric): Replace the folder source with a Fabric Pipeline/Dataflow Gen2 or Notebook that ingests the client exports into your Lakehouse, while keeping the report logic largely unchanged.
This minimizes rework and gives stakeholders a working solution quickly while providing a clear migration path to Fabric.
One question: are the CSV files all identical in structure, or do some clients produce slightly different columns? That will determine whether the built-in Combine Files experience is sufficient or whether you'll need a bit of custom Power Query logic.
I hope this helps! If you found the suggestion useful, please consider giving it a Like or marking it as the Accepted Solution so it can help others facing a similar interim ETL challenge.