# Build a refreshable Power Query pipeline from files in a folder Define a folder contract, filter the file inventory, confirm the combine sample and reconcile row counts before each refresh. - Canonical: https://satracking.net/guides/power-query-folder-combine-files-refresh-pipeline/ - Language: en - Category: platforms - Level: intermediate - Published: 2026-11-14 - Updated: 2026-11-14 --- ## When this pattern is useful Define a folder contract, filter the file inventory, confirm the combine sample and reconcile row counts before each refresh. Instead of importing each file separately, Power Query can enumerate a folder, filter its contents, combine compatible files and append their rows into one table. The source tutorial demonstrates this workflow with multiple text files: connect to a folder, inspect the file list, filter for the intended extension, use Combine Files, confirm the sample-file settings, load the result and refresh after adding later files. This guide turns that example into a controlled repeatable pipeline. ## 1. Define the folder contract Before connecting, agree on: - the folder location and who owns it; - accepted file extensions; - the expected filename pattern; - the required columns and their meanings; - delimiter, text encoding and header-row convention; - whether files are full snapshots or incremental extracts; - how duplicate or corrected files are identified. A folder query can accidentally ingest temporary files, old exports, hidden files or unrelated documents. Treat the folder as an input interface, not as an unrestricted dumping ground. A simple convention might be `sales_YYYY-MM.csv`, with one row per order line and a stable set of fields. Document whether a replacement file overwrites the previous month or whether each file is retained as a separate period. ## 2. Connect to the folder and inspect the inventory In Excel or Power BI Desktop, use the folder connector and choose the folder containing the source files. Select the option that allows you to inspect or transform the file list before loading. The inventory commonly includes file name, extension, folder path, date modified and binary content. Do not combine immediately. First inspect: - whether the folder path is the intended one; - whether all expected files are present; - whether extensions match the contract; - whether temporary or backup files are included; - whether files are unexpectedly empty or unusually small. Use a filter on extension and, where appropriate, filename or folder path. Filtering before combining reduces the risk of parsing irrelevant files. ## 3. Combine using a representative sample file The Combine Files workflow uses a sample file to infer how each file should be parsed. Confirm the sample, delimiter, file origin or encoding, and data-type detection settings. The sample should be representative of the files in the folder, not a one-off file with a different header or structure. After confirmation, Power Query creates helper queries and applies the transformation logic to each file before appending the resulting tables. This is more maintainable than manually copying and pasting every monthly export, but it creates a dependency on the sample structure and generated transformation steps. Inspect the combined output before loading: - are headers promoted correctly? - are columns aligned by name and meaning? - are delimiters interpreted correctly? - do text values contain unexpected encoding artifacts? - are dates and decimal values parsed consistently? ## 4. Preserve file lineage Keep the source filename or a derived period field in the final table. This makes it possible to trace a suspicious record back to its input file and identify which extract introduced a change. For example, retain `Source.Name` and derive `ReportingMonth` from a validated filename convention. Do not infer a month from a filename unless the naming rule is controlled and checked. A lineage field is especially useful when two files contain overlapping records. It helps distinguish a legitimate repeated business event from an accidental duplicate caused by re-exporting a period. ## 5. Validate schema and row counts A successful combine operation does not prove that all files are semantically compatible. Create checks for: - required columns present in every file; - unexpected additional columns; - data types and locale-sensitive values; - row counts by source file; - duplicate business keys; - minimum and maximum dates; - control totals such as record count or sales amount. If a new file has a renamed or missing column, do not allow it to silently shift values into the wrong field. Route it to an exception process or correct the source before refresh. ## 6. Refresh safely when new files arrive The source tutorial demonstrates adding later period files to the same folder and refreshing the model. Operationally, use a controlled sequence: 1. copy the new file into a staging folder; 2. verify its name, schema and completeness; 3. move it into the monitored folder only after validation; 4. refresh the query; 5. reconcile the new period's row count and totals; 6. record the refresh time and result. If the folder contains all historical files, every refresh may re-read them. For large collections, consider the performance and retention implications of repeatedly processing the full folder. Do not delete source files until retention and recovery requirements are understood. ## 7. Diagnose common failures **A file is missing from the combined result:** inspect extension filters, folder path, hidden-file behavior and access permissions. **The combine step errors on one file:** compare its delimiter, encoding, header row and column structure with the sample file. **Rows are duplicated after refresh:** check whether the folder contains both original and corrected exports, or whether the source process writes multiple versions. **Dates or amounts change interpretation:** inspect locale, decimal separators and automatic type-detection steps. Set types deliberately after parsing. **A new column is ignored:** review the generated transform sample and schema assumptions; update the transformation deliberately rather than patching the final table blindly. ## Release checklist Document the folder contract, filter rules, sample file, schema expectations, lineage fields, duplicate policy, refresh sequence and reconciliation checks. Test with a representative file, a malformed file and a newly added valid file. A folder query is production-ready only when both the happy path and the exception path are understood. ## Official references - Microsoft Power Tools for Data Analysis #03: Power Query Introduction — Transform & Load Data in Excel & Power BI — https://learn.microsoft.com/power-query/connectors/folder (verified 2026-11-14)