
Power Query: Complete Guide to Importing, Cleaning, Merging, Appending, and Automatic Refresh
This guide includes only procedures reproduced and verified by the editor in Excel 365. AI tools were used only as support for draft preparation.
Related guides
1. Tips by Import Source
- Folder: Read files with the same schema at once, create a list, and apply a sample transformation.
- CSV: Check the delimiter and encoding. Turn off automatic data type detection and set types manually when needed.
- Excel: Select tables only; worksheet ranges are vulnerable to structural changes.
- Web/SharePoint: Separate authentication and paths into parameters.
2. Essential Cleanup and Transformation Techniques
- Split columns by delimiter or fixed width (text preprocessing is conceptually related to the TEXT function family).
- Change data types: text numbers → 123, and standardize dates and times.
- Remove unnecessary columns, use the first row as headers, and handle Null and error values.
- Unpivot columns into rows to turn wide tables into long tables better suited for aggregation and PivotTables.
3. Append: Combine Monthly or Quarterly Files
- Go to Data > Get Data > From Folder to list files.
- Create a sample transformation to align data types and columns, then use Append Queries.
- Add derived date or month columns, then load to a table or the Data Model.
TIP If schemas differ, create a preprocessing query that keeps only matching columns, using the idea behind CHOOSECOLS.
4. Merge: Add Labels from a Code Table
- Load a code table, such as product code to category, as a separate query.
- In Merge, select the key, such as product code, and choose a join type (Left Outer is recommended).
- Use Expand to include only the columns you need, such as labels or tax rates.
In a worksheet, you can perform the same task with XLOOKUP, but Power Query is more reliable for large-scale or recurring processing.
5. Parameters and Query Dependencies
- Create parameters for folder paths, file names, and date ranges to make deployment and environment changes more resilient.
- Open the query dependency view to document the workflow, which is essential for maintenance.
6. Automatic Refresh and Performance Tips
- In query properties, set refresh when opening the file or every X minutes.
- Remove unnecessary columns and reduce row counts to lower processing volume. Change data types together in an early step.
- Connect the results to PivotTables and charts to automate reports (see the guide).
7. Eight Practical Recipes
- Append 12 monthly CSV files from a folder, then add a sales month column.
- Merge a code table to label categories and tax rates.
- Extract only the email address from text in the format “Name<Email>” by splitting and cleaning, or with functions similar to TEXTBEFORE/AFTER.
- Standardize value errors and Null values, connecting the concept to IFERROR.
- Further analyze cleaned results with FILTER/SORT/UNIQUE.
- Use =COPILOT to suggest summaries for report text, then edit them.
- Arrange the final table layout with VSTACK/HSTACK/WRAPROWS.
- Organize conditional calculations with SUMIFS/AVERAGEIFS.