Power Query in Excel: stop copying and pasting the same data every month
FAQ — What does this article answer?
Q: What is Power Query, and how can I access it?
A: Power Query is a built-in Excel tool that allows you to connect to data, clean and reshape it, and load the result into a worksheet. All of these actions are recorded as steps that you can replay. You can find it on the Data tab, in the Get & Transform Data group. The process has four stages: connect, transform, load and refresh.
Q: Which Excel versions have it?
A: Power Query has been built into Excel for Windows since version 2016, and is also available as a free Microsoft add-in for Excel 2010 and 2013. It also works in Excel for Mac and Excel Online, with a growing set of features. This makes it far more widely available than the latest formula functions, many of which require Microsoft 365.
Q: What is the difference between Merge and Append?
A: Append stacks tables that share the same columns; it adds rows (the equivalent of a UNION). Merge joins two tables on a matching key column and adds columns (the equivalent of a lookup). Append makes a table longer, while Merge makes it wider. Part 5 shows both.
Q: Do I need to learn code?
A: No, every step in this article is performed by clicking through menus. Power Query records each action in a language called M, which you can view and edit in the Advanced Editor. However, you never need to write it for the tasks here.
Q: When is it better to use Power Query than a formula?
A: When combining many files or folders, when the same import-and-clean steps are repeated regularly, when the data requires extensive cleaning before use or when the data set is large or drawn from external systems. A formula is usually better when the result must recalculate instantly, the data is small and in the workbook, or the output feeds other formulas. Part 7 draws the line.
Every organisation has the same monthly task: a folder fills with exported files containing regional sales, departmental budgets and timesheets. Someone then opens each file, copies its rows and pastes them beneath the last one. They then clean up the result by hand. This method is effective, but costly in terms of time and effort. It is also prone to human error, and the moment the source changes, the whole process must start again.
Power Query removes that chore. You only need to connect to the files once, record the cleaning and consolidation process as a series of steps, and then load the result. When next month's data arrives, a single click replays every step against the new files. This article takes you through the process from start to finish, covering importing and combining a folder, cleaning, the Merge-versus-Append distinction, building the refreshable workflow, and determining when Power Query is the right tool and when a formula is still appropriate.
Part 1: What Power Query is and how to find it
Before we look at the individual tasks, it helps to understand the overall structure of the tool.
Power Query works in four stages. First, you connect to a source, such as a CSV file, an Excel workbook, a folder or a database. You then transform the data in the Power Query Editor, where every action is recorded as an ordered applied step. You then load the finished result into the workbook as a table. Whenever the source changes, you can refresh and Excel will replay every recorded step against the new data with no re-importing or copy-pasting.
You will find Power Query on the Data tab, in the Get & Transform Data group. It has been built into Windows versions of Excel since 2016 and is available as a free add-in for versions 2010 and 2013. It is also present in Excel for Mac and Excel for the web, with a growing feature set. Under the surface, Power Query records your steps in a language called M, which is visible in the Advanced Editor. However, the tasks below are entirely menu-driven and do not require any of this.
Part 2: Importing an Excel or CSV file
The simplest starting point is a single file.
To import a CSV or text file:
- Select Get Data → From File → From Text/CSV from the Data tab (or From Text/CSV button directly in the Get & Transform Data group).
- Select the file and choose Import. A preview dialog box will appear, showing the detected delimiter and data types.
- Choose Transform Data to open the Power Query Editor and clean the data first, or Load to bring it straight into a worksheet.
To import from an Excel workbook:
- Select Data → Get Data → From File → From Workbook, then choose the file.
- In the Navigator pane, tick the worksheet, table or named range that you want, a workbook can contain several.
- Choose Transform Data or Load.
When you load, selecting the Close & Load button places the result in a new worksheet as an Excel table. Close & Load To ... offers more control over the destination: such as a table, a PivotTable, a connection only (no worksheet output — useful for intermediate queries), or the Data Model. As the output is an Excel table, it behaves like any other. The advantages of this are covered in Why every dataset should be an Excel table.
Part 3: Combining all the files in a folder
This task replaces the monthly copy-and-paste process. If a folder contains files with the same structure — for example, one file per month, region or department — Power Query can consolidate them all into one table and continue to do so as new files are added.
- Select Data → Get Data → From File → From Folder.
- Browse to the folder and select Open. A dialog box lists every file it contains.
- Verify the list, then select Combine → Combine & Transform Data. (If the folder contains a variety of file types, select Transform Data first and filter to the files you want, for example, by extension.)
- In the Combine Files dialog box, select the worksheet or object to be taken from each file, and click OK.
- Power Query will then create a Transform Sample File, which is a single example file that you clean once. Any step you apply there is applied to every file in the folder.
- Return to the main query to see the combined result, which includes a Source.Name column showing which file each row came from. Select Home → Close & Load.
The result is one table drawn from the entire folder. This is an automated alternative to the manual approach described in Combining data from multiple sheets into one and, crucially, it refreshes.
Part 4: Cleaning and transforming data
Whether you import a single file or an entire folder, the cleaning process takes place in the same location: the Power Query Editor. The idea behind it is that cleaning is a recorded list of steps, which are shown in the Applied Steps list in the 'Query Settings' pane. This means that you don't have to repeat manual edits.
The transformations you will use most, with their menu paths:
- Use the first row as headers — Transform → Use First Row as Headers, when the real column names sit in row one.
- Set the data type — select a column and use Transform → Data Type, or click the type icon in the column header. Getting types right early prevents errors later.
- Remove columns — select the columns and choose Home → Remove Columns, or Remove Other Columns to keep only what you need.
- Filter rows — click the dropdown arrow on a column header and untick the values to exclude, exactly as you would filter a table.
- Split a column — Home → Split Column → By Delimiter, to separate, say, "North-2026" into two columns.
- Remove duplicates — Home → Remove Rows → Remove Duplicates.
- Replace values — Transform → Replace Values, to standardise entries.
Each action adds an entry to the Applied Steps section. You can rename, reorder, edit or delete any step and the query will be recalculated. The important point is that this sequence is captured once and replayed with every refresh, the same process that was discussed in relation to the manual and formula-based approach in How to clean messy data in Excel.
Part 5: Merge versus Append
Two commands are used to combine queries, and confusing them is the most common mistake made early on. The distinction is simple once understood: Append adds rows, whereas Merge adds columns.
Append stacks tables that share the same columns with January's rows followed by February's, and so on. Use it when data of the same shape arrives in separate pieces:
- In the Power Query Editor, select Home → Append Queries (or Append Queries as New to create a separate result).
- Choose the two queries (or several with the Three or more tables option) to stack, and select OK.
The result is one longer table. This is the query-based equivalent of a UNION.
Merge joins two tables side by side on a matching key. Use this to bring columns from one table together with another, for example, sales figures alongside their regional targets.
- Select Home → Merge Queries.
- Select the two queries, then click on the key column in each that they both have in common (for example,
Region). - Select the join kind — Left Outer (keep all rows from the first table, the default), Inner (only matching rows), Full Outer, or the Left/Right Anti joins (rows that don't match, useful for reconciliation).
- Select OK, then expand the new column to include the required fields.
The result is one wider table. In effect, Merge is the lookup performed once and refreshed thereafter, the same is job done in a formula by XLOOKUP, INDEX and MATCH functions in a formula. The rule of thumb to remember: Append for more rows, Merge for more columns.
Part 6: Building a refreshable workflow
Everything so far has built a query. Its real value is that it never has to be built again.
Once you have finished a query, selecting Home → Close & Load To ... determines where the result is stored, in an table, a Pivot Table, a connection only, or the Data Model. From then on:
- To update everything, select Data → Refresh All. To update one query, right-click it in the Queries & Connections pane and select Refresh.
- To refresh automatically, open the query's properties (right-click → Properties) and select Refresh data when opening the file, a background refresh, or a Refresh every set number of minutes.
The monthly payoff is the whole point of the tool. Next month, simply drop the new file into the folder and select Refresh All to see the new rows flow through every recorded step into the finished report. There is no need to re-import and no copy-paste, the work you did once is the work that keeps being done.
Part 7: When Power Query is better than formulas
Power Query is powerful, but it is not the answer to every task. Using it well means recognising when a formula would be more effective.
Use Power Query when the work involves a pipeline: combining many files or a whole folder, running the same import-and-clean steps every week or month, performing extensive cleaning and reshaping before the data is usable, or handling large volumes of data from external systems. Its strength lies in the fact that the process is recorded once and refreshed thereafter, and that the source data never has to be touched by hand.
Use a formula when the work involves live calculations: the result must recalculate instantly when a cell changes; the data is small and already in the workbook; the output feeds other formulas; or the task is a quick, one-off calculation. Formulas are also the more maintainable choice when the people who own the workbook are fluent in formulas but do not know the Power Query Editor.
Two points complete the picture. Firstly, Power Query has an advantage over the newest functions in terms of availability: it is built into Excel for Windows from 2016 and works across Mac and the web, whereas many modern functions require Microsoft 365. The broader version context is in Excel 365 versus older versions. The next step when the consolidated result needs to become a reporting layer is to load it to the Data Model, as introduced in Power Pivot and the data model.
Part 8: Common pitfalls
| Symptom | Likely cause | Fix |
|---|---|---|
| Numbers arrive as text after combining | Data types are not carried through the combine step | Add a Changed Type step as the last step in the main query |
| The query breaks when the folder moves | A hard-coded file path | Rebuild the source, or use a parameter for the folder path |
| Refresh fails after a source changes | A column was renamed, added or removed at source | Keep queries tolerant; avoid steps that depend on a fixed column order |
| Stray or wrong files get pulled in | A different file type was saved in the folder | Add a filter step on the file extension early in the query |
| Nothing appears in the worksheet | The query was loaded as Only Create Connection | Use Close & Load To… → Table if you want a worksheet output |
| A prompt about credentials or privacy on refresh | Data-source permissions haven't been set | Set the source's privacy level and credentials once, then refresh |
| A slow refresh | A very large folder, or heavy steps early | Filter rows and files as early as possible in the query |
Summary
Power Query transforms a repetitive manual task into a one-time workflow that can be refreshed indefinitely.
- Connect, transform, load, refresh, the four-stage model behind everything the tool does.
- Import an Excel or CSV file with Get Data → From File; combine a whole folder with From Folder → Combine & Transform Data, which replaces the monthly copy-paste process.
- Clean in the Power Query Editor, where each action is a recorded, replayable applied step.
- Append stacks tables into more rows and Merge joins them on a key into more columns.
- Refresh, a single click, or an automatic refresh on opening, replays every step against the new data.
- Choose Power Query for repeatable pipelines over many files and a formula for live, in-sheet calculation on small data set.
The principle runs through the modern toolkit: match the tool to the problem. If your work involves combining, cleaning and consolidating the same types of data repeatedly, Power Query is the tool for you, it means you'll never have to copy and paste the same data again.
See also: Combining data from multiple sheets into one for the manual approach Power Query automates, How to clean messy data in Excel for the wider cleaning toolkit, Why every dataset should be an Excel table for the tables Power Query loads to and reads from, XLOOKUP, INDEX and MATCH for the lookup that Merge performs, Power Pivot and the data model for turning the result into a reporting model, and Excel 365 versus older versions for the availability picture.
This article is part of the helpme.safeoffice.de series, which provides practical guides on Excel functions, workbook modeling and data solutions. The series is aimed at businesses that want effective, maintainable tools that everyone can understand.