Power Query for Beginners: Clean and Combine Data in Excel

Power Query for beginners: clean messy exports, append and merge tables, and combine a folder of files in Excel without writing any code.

Power Query for Beginners: Clean and Combine Data in Excel

If you spend the first hour of every month deleting blank rows, fixing dates and copying sheets together before you can even start your report, Power Query is the tool you have been missing. This Power Query for beginners guide shows you how to clean a messy export, stack monthly files on top of each other, and match data from two tables, all by clicking buttons rather than writing code. By the end you will have a cleanup routine you build once and then repeat every month with a single Refresh.

Power Query is built into Excel 2016 and later, including Microsoft 365 on Windows and Mac, under the Data tab in the Get & Transform Data group. Power BI uses the same engine, so everything you learn here carries over.

What Power Query does (and why it beats copy and paste)

Power Query sits between your raw data and your worksheet. You point it at a source, such as a table, a CSV file, a folder or a web page, then apply cleaning steps in an editor. Each click is recorded as a step. When next month’s file arrives, you click Refresh and every step runs again on the new data.

The original file is never changed. That is a big difference from manual cleanup or a quick macro: if you make a mistake, you simply delete or edit the step, and the raw data is still there.

Your first query: clean a messy export step by step

Let us say you have a sales export with a title row at the top, blank rows, extra spaces in customer names and dates stored as text. Here is how to clean it.

  1. Click anywhere inside the data and choose Data, From Table/Range. Excel converts it to a Table if needed and opens the Power Query Editor. For a file you have not opened, use Data, Get Data, From File instead.
  2. If the real headers are not in the first row, use Home, Remove Rows, Remove Top Rows, then Home, Use First Row as Headers.
  3. Remove empty rows with Home, Remove Rows, Remove Blank Rows.
  4. Select the text columns, right click a header and choose Transform, Trim to strip leading and trailing spaces.
  5. Click the icon to the left of each column header to set the right data type: Date, Decimal Number, Whole Number or Text.
  6. Delete columns you do not need: select them and press Delete, or select the ones you want and use Remove Other Columns.
  7. Choose Home, Close & Load. The clean data lands on a new sheet as a Table.

Look at the Applied Steps pane on the right of the editor while you work. Every action appears there with a name. Click any earlier step to see what the data looked like at that point, which makes troubleshooting easy.

Handy cleaning tools and where to find them

Task Where to click
Split “City, State” into two columns Home, Split Column, By Delimiter
Fill blanks with the value above Transform, Fill, Down
Fix “N/A” or “-” values Transform, Replace Values
Remove duplicate rows Select key columns, Home, Remove Rows, Remove Duplicates
Turn month columns into rows Select ID columns, Transform, Unpivot Other Columns
Change text case Transform, Format, Capitalize Each Word
Keep only some rows Filter arrow on the column header
Add a calculated column Add Column, Custom Column

Unpivot deserves a special mention. Many reports arrive with one column per month, which is hard to sum or chart. Unpivot turns them into three tidy columns (Product, Month, Value) in one click, and it keeps working when a new month column appears.

Combine data: Append, Merge and From Folder

Cleaning one table is useful. Combining several is where Power Query really saves time.

Append queries: stack tables on top of each other

Use Append when you have the same columns in several tables, for example January, February and March sales. Load each as a query, then in the editor choose Home, Append Queries, Append Queries as New and pick the tables. Columns are matched by header name, so the order does not matter, but the spelling does.

Merge queries: the no-formula VLOOKUP

Use Merge when you want to bring columns from one table into another based on a shared key, like adding Region from a customer list to your sales data.

  1. Load both tables as queries.
  2. Select the sales query and choose Home, Merge Queries.
  3. Pick the customer table in the second dropdown and click the matching key column in both tables (for example CustomerID).
  4. Leave Join Kind as Left Outer to keep every sales row, then click OK.
  5. Click the expand icon on the new column header and tick only the columns you want, such as Region.

From Folder: combine every file in a folder

This is the feature that wins people over. Save each monthly CSV or Excel file in one folder, then choose Data, Get Data, From File, From Folder. Click Combine, Combine & Transform Data, pick a sample file and Power Query builds the whole combine logic for you, including a Source.Name column showing which file each row came from. Next month, drop the new file into the folder and click Refresh.

If you prefer a macro for this job, or need to do it on a machine where Power Query is not practical, I have a separate guide on how to combine all CSV files in a folder with Excel VBA.

A quick look at the M code behind your clicks

You never have to write code in Power Query, but it helps to know it is there. Every step you click is written in a language called M. Open Home, Advanced Editor and you will see something like this:

let
    // Read the Excel Table called tblSales
    Source = Excel.CurrentWorkbook(){[Name="tblSales"]}[Content],
    // Drop rows with no customer
    RemovedBlankRows = Table.SelectRows(Source, each [Customer] <> null and [Customer] <> ""),
    // Trim extra spaces from customer names
    TrimmedText = Table.TransformColumns(RemovedBlankRows, {{"Customer", Text.Trim, type text}}),
    // Set proper data types
    ChangedType = Table.TransformColumnTypes(TrimmedText, {{"Date", type date}, {"Amount", type number}}),
    // Keep one row per invoice number
    RemovedDuplicates = Table.Distinct(ChangedType, {"Invoice"})
in
    RemovedDuplicates

Each line is one Applied Step, and each step uses the result of the one before it. You can rename steps by right clicking them in the Applied Steps pane, which makes the code easier to read later. Microsoft’s Power Query documentation is a good reference once you are ready to edit M directly.

Common mistakes beginners make

  • Wrong date format. A file with day/month/year dates on a US system turns 03/04 into March 4. Right click the column and use Change Type, Using Locale to tell Power Query which format the source uses.
  • Renamed source columns. Steps refer to column names. If the export changes “Amount” to “Total”, the query fails with an error naming the missing column. Fix the step, or ask for a consistent export.
  • Hard-coded file paths. A query pointing at C:UsersYourNameDownloads breaks on a colleague’s PC. Keep source files in a shared or synced folder.
  • Loading huge tables to a sheet. For hundreds of thousands of rows, use Close & Load To, Only Create Connection and add the data to the Data Model, then report with a PivotTable.
  • Editing the output table by hand. Typed changes on the loaded sheet are overwritten on refresh. Make every change as a step in the query.

Frequently asked questions

Is Power Query available on Excel for Mac?

Yes, Microsoft 365 for Mac includes Power Query and its editor, but with fewer data sources than Windows. Text/CSV, Excel, JSON and tables in the current workbook can be imported, while sources like From Folder and From Web currently need Windows to create the query.

Does Power Query refresh automatically?

Not by default. Use Data, Refresh All, or open Query Properties and tick Refresh data when opening the file or set a refresh interval.

Power Query or VBA, which should I learn first?

Start with Power Query for importing and cleaning data, because it is faster to learn and easier to maintain. Use VBA when you need actions Power Query cannot do, like sending emails, formatting reports or saving files.

Will Power Query slow down my workbook?

Queries only run when you refresh, so they do not slow down normal editing. A refresh on large files can take a while, and filtering rows early in the query helps.

Want this set up for you?

If your monthly reports still start with manual cleanup, I can build the Power Query and VBA side for you as part of my Excel automation service. Get an instant price and see how much time it could free up.

12 Excel VBA macros that save hours every week

The small macros I use on almost every client file. One .bas file you import once, with clear comments and step by step instructions.

  • Unhide, protect and unprotect all sheets
  • Delete blank rows and clean messy text
  • Highlight duplicates in any range
  • Split one sheet into many by a column
  • Combine every sheet into one
  • Export each sheet to its own PDF
  • Clickable sheet index, dated backups and a formula audit list

No spam. Your email is never shared. Privacy Policy

Sourab Saha, Data Analyst

About the author

Sourab Saha · Data Analyst · Kolkata, India

I’m Sourab Saha, a data analyst and automation developer from Kolkata, India, with more than ten years of experience turning manual data work into clean, automated systems. On Fiverr and Upwork I have delivered over 500 data and automation projects for clients in the US, UK, Europe, Australia and the Middle East, with a 5.0 rating on both platforms. My toolkit is Excel VBA, SQL, Power BI and DAX, Python with Selenium, and Google Apps Script. I collect data from files, databases and websites, clean it, model it and present it so decisions take minutes instead of days. I build and test every tool on your real data, deliver it with a short walkthrough, and keep revising until it works exactly the way you need. Alongside my freelance work, since 2024 I have also worked as a Data Analyst for AH Group of Industries, a US healthcare group, building automated reports and Power BI dashboards from billing, payroll, audit and attendance data.

Rated 5.0 on Fiverr and Upwork, with more than 500 automation projects delivered and over ten years of Excel VBA. You get a fixed price before any work starts, your files stay private on your order page, and every order comes with a proper invoice.

WhatsApp