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 icassiem ,
For an MVP with only Power BI on hand, I'd stick with Power Query's "Combine files from folder" — it's the fastest path and needs zero extra tooling.
Quick approach:
- Point Power BI at your root folder (e.g., \\server\share\MatureClients\).
- Use Get Data → Folder, then filter the Name column with something like Text.StartsWith([Name], "Mature_client") before hitting Combine.
- Power Query auto-generates the sample query + transformation function, so any new CSV dropped into the folder gets picked up on the next refresh.
- Do your cleanup/transforms in the sample query — they apply to every file.
If schemas ever drift, pre-combining with PowerShell (Import-Csv | Export-Csv) or Python (pandas.concat) into one monthly file works too, but honestly it's overkill for an MVP.
Caveats worth flagging up front:
- Consistent columns across all Mature_client***.csv files — Power Query's combine step is fragile if headers shift.
- Stable folder path — moving/renaming the root breaks the query.
- Refresh limits — if the folder is local or on an on-prem share, scheduled refresh from the Power BI Service needs an On-premises Data Gateway. OneDrive/SharePoint folders refresh natively without a gateway.
- Treat this as a stopgap until Fabric lands — don't over-invest in the plumbing.
Some clarifying Questions:
- Where do the CSVs actually live — local drive, network share, SharePoint/OneDrive?
- Is the schema guaranteed identical across clients, or do columns vary?
- Do you need scheduled refresh from the Service, or is desktop refresh enough for now?
Useful refrences:
Power Query Combine Files
Power Query Import Data From Folder
Service Gateway Onprem
If this got you what you needed, a Kudos and an Accepted Solution mark would be great — it helps others searching for the same thing find the answer quicker.
- icassiem2 months ago
Post Prodigy
Dev_Dholakia Thank You
the issue is i have no etl to loop on wildcard and place the many client x 5 sources to create a combined 5 sources for powerbi then to transform, as the filenames differ + timestamped but it i can ask the user that places it to name it in a certain manner and overwrite but when clients gest added or dropped of the powerbi build to append/merge will fail. so im hoping theres another method to take all files and merge them into a client source per source type before pwoerbi
i was looking at python or powershell to do execute even once a month but honestly i have no clue with this either. the business cant wait 3-5 months untill the neviorment fabirc is fully up