Knowledge hub

Power Query in Excel — step by step guide

You can use Excel without Power Query, but if you're doing the same formatting and reporting steps every week or month, it's worth the time to set it up.

Setting up Power Query in Excel

Power Query lets you pull data from various sources, edit it — combining across sources, splitting or adding columns, filtering — then load it into Excel and build Pivot Tables or charts from it. Like a macro, the steps are recorded so the same query can run again on next month's data, and you can add, remove, or reorder steps whenever you need to.

Power Query setup from a folder source

Querying and loading the data

Start from Data > New Query. You can create a query from a workbook, CSV, text file, XML, or folder:

Power Query new query source options
Which source should I pick? If you'll be adding new data files regularly, save them all in one folder and create the query from Folder — new files get picked up automatically on refresh. If you're working with a single file that gets updated in place, use Workbook or CSV depending on the file type.

Using a folder source: go to Data > New Query > From Folder, then paste or browse to the directory:

Selecting a folder path for Power Query

You'll see the list of files in that folder. This step just combines and loads the data — for editing and transforming, see the next section.

Combining and loading files from a folder in Power Query
Before loading, make sure all files share the same headings — those headings become the headings for all loaded data. It's better to fix inconsistencies here in Power Query than to edit the raw source files every time.
Matching headings across files before loading in Power Query

Once loaded, use the filter on the Source.Name column to quickly confirm every file made it in:

Filtering by Source.Name to verify all files loaded

From there, Pivot Tables pair naturally with Power Query — both can be refreshed with a single click once set up.

Loading new data

Once a query is built from a folder path, updating it is simple:

  • Download the new report
  • Save it into the same folder
  • Click Refresh in the Excel file
Refresh button for Power Query data

And the new data appears:

New data loaded after refreshing Power Query

Transforming/editing data

Before loading, you can format the data first — the steps are recorded and re-run on refresh, and can be edited afterward. To start editing before loading:

Transforming data before loading in Power Query

Splitting columns

  1. Select the column to split
  2. Go to the Transform tab
  3. Select Split Column > By Delimiter
  4. Choose the delimiter — e.g. Custom, and enter "-"
Splitting a column by delimiter in Power Query Custom delimiter setting for splitting a column

The end result:

Result of splitting a column by delimiter

Day of the week

  1. Select the column with dates
  2. Go to the Transform tab
  3. Select Date > Day > Name of Day
Calculating day of the week in Power Query

The result:

Day of week result in Power Query

Filtering columns

Removing irrelevant information before loading saves time down the line — select the relevant column, then deselect what you don't need. Here's an example filtering for session cancellations:

Filtering a column in Power Query

The result:

Filtered result in Power Query

Conditional formatting

This works like an IF function:

  1. Go to the Add Column tab
  2. Select Conditional Column
  3. Apply the condition you need

Example: grouping members into age brackets.

Conditional column setup in Power Query

The result:

Conditional formatting result grouping ages

Editing the applied steps

Unlike editing a macro through VBA, Power Query's recorded steps are easy to edit directly through Query Settings on the right-hand panel — go to View > Query Settings if it's not visible.

You can drag to reorder steps, click the cross to delete one, or open settings to change formatting rules. Be careful when editing: deleting an early step can break later steps that depend on it.

Editing applied steps in Power Query

Combining/merging data

You can merge files together as long as they share common data to connect them — e.g. monthly sales reports and a master file of employee or client details.

  1. Load the first set of data
  2. Load the second file
  3. Right-click one of the queries in Workbook Queries
  4. Select Merge
  5. Select the second dataset to merge in
  6. Match the connecting columns in both datasets
  7. Click Ok
  8. Select the columns to merge into the first dataset
  9. Close & Load
Merging queries in Power Query Selecting datasets and matching columns to merge Selecting columns to merge into the first dataset

The new merged table:

Final merged table in Power Query

Extracting file names and path directories

The easiest way to extract file names and folder paths is to create a Power Query from the folder itself:

  1. Go to Data > New Query > From File > From Folder
  2. Paste or browse to the folder path
  3. Select Load (don't select Combine)
If there are lots of files and subfolders, select Edit and filter to what you actually need — e.g. filtering the extension column to only load CSV and XLS files.
Loading file paths from a folder in Power Query Filtering file extensions in Power Query

Once you finish editing, Close & Load gives you a list of every file name in that folder (and its subfolders), along with each file's path.

Stuck on a Power Query step we haven't covered? Let us know and we'll add it.

Get in touch